AppML Lists and Forms

AppML ships built-in helpers that turn a model's records into a repeating list and turn a model's field definitions into a ready-made input form.

Rendering a List From Records

The appml-repeat attribute marks an element as a template that is repeated once for every record returned by the model. Inside that element, {{fieldname}} placeholders are resolved separately for each row, so a single row of markup produces a whole table or list without any hand-written looping code.

A repeating list

<table>
  <tr appml-repeat="records">
    <td>{{firstname}}</td>
    <td>{{lastname}}</td>
    <td>{{department}}</td>
  </tr>
</table>

Generating a Form From Fields

Rather than hand-writing every input element, AppML can walk the model's fields definition and produce one labeled input per field - pre-filled when editing an existing record, blank when inserting a new one - and connect the form's submit action to the model's insert or update action.

A model-driven form

<form appml-data="employees.json" appml-action="insert">
  <input name="firstname" placeholder="{{firstname}}">
  <input name="lastname" placeholder="{{lastname}}">
  <input name="department" placeholder="{{department}}">
  <button type="submit">Save</button>
</form>
  • Text fields become plain text inputs
  • Number fields become inputs that expect numeric values
  • Fields marked required are validated before the form submits
  • Fields left out of the model simply never appear on the form
Note: Fields left out of the model's fields definition never get an automatic input. If a column should stay hidden from the form - like an internal id - omit it there instead of hiding it with CSS.
HelperWhat it does
appml-repeatRepeats an element once per record returned by the model
appml-ifShows or hides an element based on a condition
Auto-generated formBuilds one input per declared field, wired to insert/update

Exercise: AppML Client Features

Which client feature lets users click a column header to reorder records?