Commit 0cd1ad2c authored by Carsten  Rose's avatar Carsten Rose
Browse files

Fixes #7434 - turn user/support message. Also removed '!' requirement for sqlValidate in '{{!...'.

parent f28ce036
Pipeline #1103 passed with stage
in 1 minute and 54 seconds
......@@ -1178,7 +1178,7 @@ glue string.
Result: row
'''''''''''
A few functionalities needs more than a returned string, instead separate columns are necessary. To indicate an array
A few functions needs more than a returned string, instead separate columns are necessary. To indicate an array
result, specify those with an '!': ::
{{!SELECT ...}}
......@@ -1722,7 +1722,7 @@ Store: *VARS* - V
The directive `fillStoreVar` will fill the store VARS with custom values. Existing Store VARS values will be merged together with them.
E.g.: ::
fillStoreVar = {{!SELECT p.name, p.email FROM Person AS p WHERE p.id={{pId:S}} }}
fillStoreVar = {{SELECT p.name, p.email FROM Person AS p WHERE p.id={{pId:S}} }}
* After filling the store, the values can be retrieved via `{{name:V}}` and `{{email:V}}`.
* Be careful by specifying general purpose variables like `id`, `r`, `pageId` and so on. This might conflict with existing variables.
......@@ -2874,6 +2874,12 @@ See also at specific *FormElement* definitions.
+------------------------+--------+----------------------------------------------------------------------------------------------------------+
| trim | string | By default, whitespace is trimmed. To disable, use 'trim=none'. You can also specify custom trim |
| | | characters: 'trim=\\ ' only trims spaces. |
+------------------------+--------+----------------------------------------------------------------------------------------------------------+
| sqlValidate | string | See `sqlValidate`_ |
+------------------------+--------+ |
| expectRecords | int | | |
+------------------------+--------+ |
| messageFail | string | |
+------------------------+--------+----------------------------------------------------------------------------------------------------------+
......@@ -3731,6 +3737,8 @@ Types:
* afterDelete
* paste (configure copy/paste forms)
.. _sqlValidate:
Parameter: sqlValidate
''''''''''''''''''''''
......@@ -3742,12 +3750,11 @@ Parameter: sqlValidate
*FormElement.parameter*:
* *requiredList* = `<fe.name[s]>` - List of `native`-*FormElement* names: only if all of those elements are filled (!=0 and !=''), the *current*
`action`-*FormElement* will be processed. This will enable or disable the check, based on the user input! If no
`native`-*FormElement* names are given, the specified check will always be performed.
* *sqlValidate* = `{{<query>}}` - validation query. E.g.: `sqlValidate={{!SELECT id FROM Person AS p WHERE p.name LIKE {{name:F:all}} AND p.firstname LIKE {{firstname:F:all}} }}`
* *requiredList* = `<fe.name[s]>` - List of `native`-*FormElement* names: only if all of those elements are filled
(!=0 and !=''), the *current* `action`-*FormElement* will be processed. This will enable or disable the check,
based on the user input! If no `native`-*FormElement* names are given, the specified check will always be performed.
* Pay attention to `{{!...` after the equal sign.
* *sqlValidate* = `{{<query>}}` - validation query. E.g.: `sqlValidate={{SELECT id FROM Person AS p WHERE p.name LIKE {{name:F:all}} AND p.firstname LIKE {{firstname:F:all}} }}`
* *expectRecords* = `<value>`- number of expected records.
......@@ -4227,7 +4234,7 @@ form with the following parameter
* Type: `beforeSave`
* Parameter:
* `sqlValidate={{!SELECT f.id FROM Form AS f WHERE f.name LIKE '{{myName:FE:alnumx}}' LIMIT 1}}`
* `sqlValidate={{SELECT f.id FROM Form AS f WHERE f.name LIKE '{{myName:FE:alnumx}}' LIMIT 1}}`
* `expectRecords = 0`
* `messageFail = There is already a form with this name`
* `sqlAfter={{DELETE FROM Clipboard WHERE cookie='{{cookieQfq:C0:alnumx}}' }}`
......@@ -4340,7 +4347,7 @@ On `Form.parameter` define a `fillStoreVar` query with a column name equal to a
Example: ::
FormElement.name = technicalContact
Form.parameter.fillStoreVar = {{!SELECT CONCAT(p.firstName, ' ', p.name) AS technicalContact FROM Person AS p WHERE p.account='{{feUser:T}}' }}
Form.parameter.fillStoreVar = {{SELECT CONCAT(p.firstName, ' ', p.name) AS technicalContact FROM Person AS p WHERE p.account='{{feUser:T}}' }}
What we use here is the default STORE prio FSRVD. If the form loads with r=0, 'F', 'S' and 'R' are empty. 'V' is filled.
If r>0, than 'F' and 'S' are empty and 'R' is filled.
......
......@@ -305,7 +305,7 @@ class FormAction {
}
// Do the check
$result = $this->evaluate->parse($fe[FE_SQL_VALIDATE]);
$result = $this->evaluate->parse($fe[FE_SQL_VALIDATE], ROW_REGULAR);
if (!is_array($result)) {
throw new UserFormException("Expected an array for '" . FE_SQL_VALIDATE . "', got a scalar. Please check for {{!...", ERROR_EXPECTED_ARRAY);
}
......@@ -321,7 +321,7 @@ class FormAction {
$msg = $this->evaluate->parse($fe[FE_MESSAGE_FAIL]); // Replace possible dynamic parts
// Throw user error message
throw new UserFormException(json_encode([ERROR_MESSAGE_TO_USER => 'validate() failed', ERROR_MESSAGE_SUPPORT => $msg]), ERROR_REPORT_FAILED_ACTION);
throw new UserFormException( json_encode([ERROR_MESSAGE_TO_USER => $msg, ERROR_MESSAGE_SUPPORT => 'validate() failed']), ERROR_REPORT_FAILED_ACTION);
}
......
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