Commit 5692b3c5 authored by Carsten  Rose's avatar Carsten Rose
Browse files

Index.rst: added some lines to 'dynamicUpdate'

AbstractBuildForm.php, QuickFormQuery.php: documentation updates, code reformat.
parent 815b902a
......@@ -820,6 +820,9 @@ Fields:
| | 'disabled' ) | *Readonly*: user can't change any data. Data not saved. |
| | | *Disabled*: *FormElement* is not visible. |
+---------------+-----------------------------+---------------------------------------------------------------------------------------------------+
|modeSql | `select` statement with | A value given here overwrites the setting from `mode`. Most usefull with :ref:`dynamic-update`. |
| | a value like in `mode` | E.g.: {{SELECT IF( '{{otherFunding:FR:alnumx}}'='yes' ,'show', 'hidden' }} |
+---------------+-----------------------------+---------------------------------------------------------------------------------------------------+
|class | enum('native', 'action', | Details below. |
| | 'container') | |
+---------------+-----------------------------+---------------------------------------------------------------------------------------------------+
......@@ -1615,21 +1618,43 @@ The 'Dynamic Update' feature makes a form more interactive. If a user change a *
'dynamicUpdate', *all* elements who are tagged with 'DynamicUpdate', will be recalculated and rerendered.
The following fields will be recalculated during 'Dynamic Update'
* 'modeSql' - Possible values: 'show', 'required', 'readonly', 'hidden'
* 'value'
* 'parameter.*' - especially 'itemList'
* 'modeSql' - Possible values: 'show', 'required', 'readonly', 'hidden'
* 'value'
* 'parameter.*' - especially 'itemList'
* 'note'
* 'label'
To make a form dynamic:
* Mark all *FormElements* with {dynamic update}=enabled, which should send **or** receive a 'do update' signal.
* Define the receiving *FormElements* in a way, that they will interpret the recent user change. The form variable of the
specific sender *FormElement* `{{<sender element>:F:<sanitize>}}` should be part of one of the above fields to get an
impact. E.g.:
::
* Mark all *FormElements* with `dynamic update`=`enabled`, which **initiates** or **receives** updates.
* Define the receiving *FormElements* in a way, that they will interpret the recent user change. The form variable of the
specific sender *FormElement* `{{<sender element>:F:<sanitize>}}` should be part of one of the above fields to get an
impact. E.g.:
::
[receiving *FormElement*].parameter: itemList={{ SELECT IF({{carPriceRange:FE:alnumx}}='expensive','Ferrari,Tesla,Jaguar','General Motors,Honda,Seat,Fiat') }}
* Label and Description are not 'Dynamic Update' aware (Feature Request #2081).
Examples
^^^^^^^^
* Master FormElement 'music' is a radio/enum of 'classic', 'jazz', 'pop'.
Content of a select list
''''''''''''''''''''''''
* Slave FormElement 'interpret' is 'select'-list, depending of 'music':
::
sql={{!SELECT name FROM interpret WHERE music={{music:FE:alnumx}} ORDER BY name}}
Show / Hide a *FormElement*
'''''''''''''''''''''''''''
* Slave 'interpret' is displayed only for 'pop':
::
modeSql={{SELECT IF( '{{music:FR:alnumx}}'='pop' ,'show', 'hidden' }}
.. _form-layout:
......
......@@ -135,7 +135,7 @@ abstract class AbstractBuildForm {
abstract public function fillWrap();
/**
* Builds complete form. Depending of form specification, the layout will be 'plain' / 'table' / 'bootstrap'.
* Builds complete 'form'. Depending of form specification, the layout will be 'plain' / 'table' / 'bootstrap'.
*
* @param string $mode FORM_LOAD | FORM_UPDATE | FORM_SAVE
* @return string|array $mode=LOAD_FORM: The whole form as HTML, $mode=FORM_UPDATE: array of all formElement.dynamicUpdate-yes values/states
......@@ -330,7 +330,7 @@ abstract class AbstractBuildForm {
abstract public function getProcessFilter();
/**
* Process all FormElements: build corresponding HTML code. Collect and return all HTML code.
* Process all FormElements: build corresponding HTML code. Collect and return all HTML code & JSON.
*
* @param $recordId
* @param string $filter FORM_ELEMENTS_NATIVE | FORM_ELEMENTS_SUBRECORD | FORM_ELEMENTS_NATIVE_SUBRECORD
......@@ -346,7 +346,8 @@ abstract class AbstractBuildForm {
* @throws \qfq\UserFormException
*/
public function elements($recordId, $filter = FORM_ELEMENTS_NATIVE, $feIdContainer = 0, array &$json,
$modeCollectFe = FLAG_DYNAMIC_UPDATE, $htmlElementNameIdZero = false, $storeUse = STORE_USE_DEFAULT, $mode = FORM_LOAD) {
$modeCollectFe = FLAG_DYNAMIC_UPDATE, $htmlElementNameIdZero = false,
$storeUse = STORE_USE_DEFAULT, $mode = FORM_LOAD) {
$html = '';
$flagOutput = false;
......@@ -355,7 +356,9 @@ abstract class AbstractBuildForm {
// get current data record
if ($recordId > 0 && $this->store->getVar('id', STORE_RECORD) === false) {
$row = $this->db->sql("SELECT * FROM " . $this->formSpec[F_TABLE_NAME] . " WHERE id = ?", ROW_EXPECT_1, array($recordId), "Form '" . $this->formSpec[F_NAME] . "' failed to load record '$recordId' from table '" . $this->formSpec[F_TABLE_NAME] . "'.");
$row = $this->db->sql("SELECT * FROM " . $this->formSpec[F_TABLE_NAME] . " WHERE id = ?", ROW_EXPECT_1,
array($recordId), "Form '" . $this->formSpec[F_NAME] . "' failed to load record '$recordId' from table '" .
$this->formSpec[F_TABLE_NAME] . "'.");
$this->store->setStore($row, STORE_RECORD);
}
......@@ -687,7 +690,7 @@ abstract class AbstractBuildForm {
* @param array $formElement
* @param string $htmlFormElementName
* @param string $value
* @param array $json
* @param array $json Return updates in this array - will be later converted to JSON.
* @param string $mode FORM_LOAD | FORM_UPDATE | FORM_SAVE
* @return string complete rendered HTML input element.
* @throws \qfq\UserFormException
......
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