Commit a879fb54 authored by Carsten  Rose's avatar Carsten Rose
Browse files

Feature #4356 / Form: required parameter - split between 'New' & 'Edit'

parent cde7fa78
......@@ -1627,7 +1627,9 @@ Definition
+-------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------+
|Table | Primary table of the form. _`form-tablename` |
+-------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------+
|Required Parameter | Name of required SIP parameter, seperated by comma. '#' as comment delimiter. See `form-requiredParameter`_ |
|Required Parameter NEW | Name of required SIP parameter to create a new record (r=0), separated by comma. '#' as comment delimiter. See `form-requiredParameter`_ |
+-------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------+
|Required Parameter EDIT | Name of required SIP parameter to edit an existing record (r>0), separated by comma. '#' as comment delimiter. See `form-requiredParameter`_ |
+-------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------+
|Permit New | 'sip, logged_in, logged_out, always, never' (Default: sip): See `form-permitNewEdit`_ |
+-------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------+
......@@ -1711,12 +1713,21 @@ Depending on `r`, the following access permission will be taken:
.. _`form-requiredParameter`:
Required Parameter
^^^^^^^^^^^^^^^^^^
Required Parameter NEW|EDIT
^^^^^^^^^^^^^^^^^^^^^^^^^^^
Comma separated list of variable names. On form load, an error message will be shown in case of missing parameters.
The parameters must be given by SIP.
Comma separated list of variable names. The form will show an error message, if it was called without the named
parameters. Especially subforms often requires additional parameters - if such parameters are missing, the record cannot
saved correctly. The parameters must be given by SIP.
The list of required parameter has to be defined for 'NEW' (r=0, create a new record) and for 'EDIT' (r>0, edit existing
record).
Optional a comment might be attached to the parameter, direct after the parameter name. The comment should not contain any ','.
E.g.: ::
NEW: grId, pId # Always specify a person, grId2
EDIT: pId
.. _`form-showButton`:
......@@ -3289,7 +3300,7 @@ See #3426 / Dynamic Update: Inputs loose the new content and shows the old value
* On **all** `dynamic update` *FormElements* an explicit definition of `value`, including a sanitize class, is necessary
(except the field is numeric). **A missing definition let's the content overwrite all the time with the old value**.
A typical definition for `value` looks like::
A typical definition for `value` looks like (default store priority is: FSRVD)::
{{<FormElement name>::alnumx}}
......@@ -3303,6 +3314,10 @@ See #3426 / Dynamic Update: Inputs loose the new content and shows the old value
Remember to specify a 'sanitize' class - a missing sanitize class means 'digit', every content, which is not numeric,
violates the sanitize class and becomes therefore an empty string!
* If the dynamic update should work on existing and *new* records, it's important to guarantee that the query result is not empty!
even if the primary record does not exist! E.g. use a `LEFT JOIN`. The following query is ok for `new` and `edit`. ::
{{SELECT IF( IFNULL(adr.type,'') LIKE '%token%','show','hidden') FROM (SELECT 1) AS fake LEFT JOIN Address AS adr ON adr.type='{{type:FR0}}' LIMIT 1}}
Examples
^^^^^^^^
......
......@@ -704,7 +704,8 @@ const F_ID = 'id';
const F_NAME = 'name';
const F_TITLE = 'title';
const F_TABLE_NAME = 'tableName';
const F_REQUIRED_PARAMETER = 'requiredParameter';
const F_REQUIRED_PARAMETER_NEW = 'requiredParameterNew';
const F_REQUIRED_PARAMETER_EDIT = 'requiredParameterEdit';
const F_EXTRA_DELETE_FORM = 'extraDeleteForm';
const F_FINAL_DELETE_FORM = 'finalDeleteForm';
const F_DIRTY_MODE = 'dirtyMode';
......
......@@ -891,7 +891,7 @@ class QuickFormQuery {
// Retrieve record_id either from SIP (prefered) or via URL
$r = $this->store->getVar(SIP_RECORD_ID, STORE_SIP . STORE_TYPO3 . STORE_CLIENT, '', $recordIdFoundInStore);
// Set missing 'r'.
// If not found: Fake a definition in STORE_TYPO3.
if ($r === false) {
$r = 0;
$this->store->setVar(TYPO3_RECORD_ID, $r, STORE_TYPO3);
......@@ -943,7 +943,8 @@ class QuickFormQuery {
if ($formMode !== FORM_DELETE) {
$sipArray = $this->store->getStore(STORE_SIP);
// Check: requiredParameter: '' or 'form' or 'form,grId' or 'form #formname for form,grId'
$param = explode(',', $this->formSpec[F_REQUIRED_PARAMETER]);
$requiredParameter = ($r > 0) ? $this->formSpec[F_REQUIRED_PARAMETER_EDIT] : $this->formSpec[F_REQUIRED_PARAMETER_NEW];
$param = explode(',', $requiredParameter);
foreach ($param AS $name) {
$name = explode('#', $name, 2);
......
......@@ -72,6 +72,12 @@ $UPDATE_ARRAY = array(
"ALTER TABLE `FormElement` ADD `parameterLanguageD` TEXT NOT NULL AFTER `parameterLanguageC`",
],
'0.21.0' => [
"ALTER TABLE `Form` CHANGE `requiredParameter` `requiredParameterNew` VARCHAR( 255 ) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT ''",
"ALTER TABLE `Form` ADD `requiredParameterEdit` VARCHAR( 255 ) NOT NULL AFTER `requiredParameterNew`",
"UPDATE Form SET requiredParameterEdit=requiredParameterNew",
],
);
......
......@@ -11,7 +11,8 @@ CREATE TABLE IF NOT EXISTS `Form` (
`permitEdit` ENUM('sip', 'logged_in', 'logged_out', 'always', 'never') NOT NULL DEFAULT 'sip',
`escapeTypeDefault` VARCHAR(32) NOT NULL DEFAULT 'c',
`render` ENUM('bootstrap', 'table', 'plain') NOT NULL DEFAULT 'bootstrap',
`requiredParameter` VARCHAR(255) NOT NULL DEFAULT '',
`requiredParameterNew` VARCHAR(255) NOT NULL DEFAULT '',
`requiredParameterEdit` VARCHAR(255) NOT NULL DEFAULT '',
`dirtyMode` ENUM('exclusive', 'advisory', 'none') NOT NULL DEFAULT 'exclusive',
`showButton` SET('new', 'delete', 'close', 'save') NOT NULL DEFAULT 'new,delete,close,save',
`multiMode` ENUM('none', 'horizontal', 'vertical') NOT NULL DEFAULT 'none',
......@@ -27,10 +28,10 @@ CREATE TABLE IF NOT EXISTS `Form` (
`bsNoteColumns` VARCHAR(255) NOT NULL DEFAULT '',
`parameter` TEXT NOT NULL,
`parameterLanguageA` TEXT NOT NULL,
`parameterLanguageB` TEXT NOT NULL,
`parameterLanguageC` TEXT NOT NULL,
`parameterLanguageD` TEXT NOT NULL,
`parameterLanguageA` TEXT NOT NULL,
`parameterLanguageB` TEXT NOT NULL,
`parameterLanguageC` TEXT NOT NULL,
`parameterLanguageD` TEXT NOT NULL,
`recordLockTimeoutSeconds` INT(11) NOT NULL DEFAULT 900,
`deleted` ENUM('yes', 'no') NOT NULL DEFAULT 'no',
......@@ -220,7 +221,8 @@ VALUES
'<a href="{{DOCUMENTATION_QFQ:Y}}#multi-language-form">Info</a>', '', '', '', '', 1, '', '{{SELECT IF("{{FORM_LANGUAGE_C_ID:YE}}"="","hidden","show" ) }}', '', 'none', 'no', ''),
(1, 'parameterLanguageD', 'Language: {{FORM_LANGUAGE_D_LABEL:YE}}', 'show', 'text', 'all', 'native', 160, '60,2', 0,
'<a href="{{DOCUMENTATION_QFQ:Y}}#multi-language-form">Info</a>', '', '', '', '', 1, '', '{{SELECT IF("{{FORM_LANGUAGE_D_ID:YE}}"="","hidden","show" ) }}', '', 'none', 'no', ''),
(1, 'requiredParameter', 'Required Parameter', 'show', 'text', 'all', 'native', 200, 0, 0, '<a href="{{DOCUMENTATION_QFQ:Y}}#form-requiredParameter">Info</a>', '', '', '', '', 2, '', '', '', 'specialchar', 'no', ''),
(1, 'requiredParameterNew', 'Required Parameter NEW', 'show', 'text', 'all', 'native', 200, 0, 0, '<a href="{{DOCUMENTATION_QFQ:Y}}#form-requiredParameter">Info</a>', '', '', '', '', 2, '', '', '', 'specialchar', 'no', ''),
(1, 'requiredParameterEdit', 'Required Parameter EDIT', 'show', 'text', 'all', 'native', 200, 0, 0, '<a href="{{DOCUMENTATION_QFQ:Y}}#form-requiredParameter">Info</a>', '', '', '', '', 2, '', '', '', 'specialchar', 'no', ''),
(1, 'permitNew', 'Permit New', 'show', 'radio', 'all', 'native', 210, 0, 10, '<a href="{{DOCUMENTATION_QFQ:Y}}#form-permitNewEdit">Info</a>', '', '', '', 'buttonClass=btn-default', 2, '', '', '', 'specialchar', 'no', ''),
(1, 'permitEdit', 'Permit Edit', 'show', 'radio', 'all', 'native', 220, 0, 10, '<a href="{{DOCUMENTATION_QFQ:Y}}#form-permitNewEdit">Info</a>', '', '', '', 'buttonClass=btn-default', 2, '', '', '', 'specialchar', 'no', ''),
(1, 'escapeTypeDefault', 'Escape type default', 'show', 'radio', 'all', 'native', 230, 0, 10, '<a href="{{DOCUMENTATION_QFQ:Y}}#variable-escape">Info</a>', '', '', '',
......@@ -259,7 +261,7 @@ VALUES
#
# FormEditor: FormElement
INSERT INTO Form (id, name, title, noteInternal, tableName, permitNew, permitEdit, render, multiSql, parameter, requiredParameter)
INSERT INTO Form (id, name, title, noteInternal, tableName, permitNew, permitEdit, render, multiSql, parameter, requiredParameterNew)
VALUES
(2, 'formElement',
'Form Element Editor. Form : {{SELECT f.id, " / ", f.name FROM Form AS f WHERE f.id = {{formId:S0}} }}',
......
Supports Markdown
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