Alcove CMS
Ru

Part III, Interaction

Forms and regions

Post to a live page and swap only the marked element.

form: in an alcove makes it the front of a form. to names the page that receives it, and the posted values work on that page exactly like the query string, so the filters from the previous sections apply.

Mark an element with alcove-form="name" on both pages. The answer to the post is the page the form was sent from, with only that element replaced by the receiving page's version of it.

Here the form posts to this page itself. Search for a word: the list below the form changes, the rest of the page does not.

Live result This page is rendered on request.

  • War and Peace Leo Tolstoy, 1869

No title contains that.

Source the files behind the result above

content/alcoves/demo_booksearch/alcove.yaml

fields:
  - name: q
    type: text
form:
  to: docs-forms
  fields: [q]

content/alcoves/demo_booksearch/blueprint.html

<form class="finder" action="{{ form.action }}#live" method="{{ form.method }}" role="search">
  {{ form.hidden }}
  <label for="bs-q">Search the titles</label>
  <div class="finder-row">
    <input id="bs-q" name="title-in" type="search" value="{{ query.title-in }}" placeholder="war, house, the">
    <button class="btn btn-dark" type="submit">Search</button>
  </div>
</form>

content/alcoves/demo_bookhits/blueprint.html

<div class="hits" alcove-form="demo_booksearch" data-empty="{{ no_results }}">
  <ul>{{ tiles }}</ul>
  <p class="empty">No title contains that.</p>
</div>