Commit 7d1bebae authored by Carsten  Rose's avatar Carsten Rose
Browse files

Form.rst: Update doc of Multi-Form

parent 4e8a3e3f
Pipeline #5359 passed with stages
in 3 minutes and 26 seconds
......@@ -2606,7 +2606,9 @@ record (defined by `multiSql`).
| multiMgsNoRecord | Default: No data | Message shown if `multiSql` selects no records |
+------------------+----------------------------------+------------------------------------------------+
* Multi Form do not use 'record-locking' at all.
.. note::
Multi Form do not use 'record-locking' at all.
The Form is shown as a HTML table.
......@@ -2615,25 +2617,25 @@ The Form is shown as a HTML table.
* A uniq column 'id' or '_id' (not shown) is mandatory and has to reflect an existing record id in table `primary table`.
* Additional columns, defined in `multiSql`, will be shown on the form in the same line, before the FormElements.
* Per row, the STORE_PARENT is filled with the current record of the primary table.
The following definition of *Simple* and *Advanced* is just for explanation, there is no *flag* or *mode* which
has to be set. Also the *Simple* and *Advanced* variant can be mixed in the same Multi Form.
Simple
^^^^^^
General:
* All FormElements uses columns of the primary table.
* QFQ handles all updates - that's why it's called *Simple*.
* It's not possible to create new records in simple mode, only existing records can be modified.
Form:
* Per row, the STORE_RECORD is filled with the whole record of the primary table, referenced
by `multiSql.id`.
FormElement:
* The FormElement.name represents a column of the defined primary table.
* The existing values of such FormElements are automatically loaded.
* No further definition is required.
* No further definition (sqlInsert, sqlUpdate, ...) is required.
Advanced
^^^^^^^^
......@@ -2642,6 +2644,37 @@ To handle foreign records (insert/update/delete), use the :ref:`slave-id` concep
Typically the `FormElement.name` is not a column of the primary table.
Example of how to edit the address of each person, saved in a separate address record::
# Iterate over all person in the database. If there are 10 persons in the table person, than 10 rows are shown.
Form.multiSql = {{!SELECT p.name, p.id AS _id FROM Person AS p}}
# Only one input field in this example: street. It's saved in table *Address*.
FE.name = myStreet
FE.type = text
# ``{{street:VE}}`` will be set via ``fillStoreVar``.
FE.value = {{street:VE}}
# Select the first address record owned by the current person.id = ``{{id:R}}`` ( or ``{{id:P}}``)
# Task 1: Get the ``slaveId`` (Address.id).
# Task 2: Get the value of column *street*.
FE.parameter.fillStoreVar={{!SELECT a.id AS aId, a.street FROM Address AS a WHERE a.personId={{id:R}} ORDER BY a.id LIMIT 1}}
# Set the slaveId. If there is no address, than {{aId:V}} doesn't exist and will be replaced by 0.
FE.parameter.slaveId={{aId:V0}}
# Update existing Address record.
FE.parameter.sqlUpdate={{UPDATE Address SET street='{{myStreet:FE:allbut}}' WHERE id={{slaveId:V}} }}
# Create new Address record.
FE.parameter.sqlInsert={{INSERT INTO Address (personId, street) VALUES ({{id:R0}}, '{{myStreet:FE:allbut}}') }}
# In case FE *myStreet* is empty, remove the whole Address record.
FE.parameter.sqlHonorFormElements = myStreet
FE.parameter.sqlDelete = {{DELETE FROM Address WHERE id={{slaveId:V}} }}
.. _multiple-languages:
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment