Form file syntax

To start, here's a sample of a form file.

<form id="cust_entity">
  <field id="cust_type" flags="hidden"/>
  <field id="cust_id" flags="RO"/>
  <field id="cust_class_no"/>
  <when field="cust_type" equals="C">
    <field id="vat_id"/>
    <field id="name" label="Name"/>
    <field id="def_payment_term"/>
  <when field="cust_type" equals="P">
    <field id="title" label="Title"/>
    <field id="name2" label="Firstname"/>
    <field id="name" label="Lastname"/>

The <form> tag encloses everything, and the id attribute must match the name of the file and the table. To display a field, the shortest version is to simply write <field id="fieldname"/>. The label will be extracted from the table definition file, or left empty if a label isn't defined. It's also possible to override the label using label="new label". Two flags exist, hidden used to enter a hidden field, and RO to simply show the content without allowing it to be edited.

The <when> tag withattributes field and equals gives a primitive option to tailor forms to the content of the row being edited. It works less well when adding new records, so if used it's handy to create a wizard for adding new records to the table. Everything between the start and end tag of <when> will only be shown if the term is true.

The last tag is <list> and here's an example of that:

  <list id="actual_days">
    <table id="nwd_date" using="nwd_no" link="edit"/>
    <display table="nwd_date" field="nwd_date" label="Date"/>
    <display virtual="select date_format(nwd_date,'%W in %M')" field="weekday" label="Weekday" flags="no_filter"/>

The id parameter, actual_days in the example, has to be unique but is currently unused apart from that condition. Two tags can be inside, <table> with and id telling what table to use, a using= that tells what field to link via in the query used to extract it and a link that tells the display what operations are allowed. link="edit,delete,add" will allow records in the table identified by id to be edited, deleted and added. <display> gives the columns to use and it has the table and field to show as well as a label. It's possible to forgo the table and field and instead use virtual that will run a subquery inside to get a single value returned in that column. Flags can be no_filter - meaning that you can't filter the list based on that column.