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

Feature #4283 / FE.parameter=emptyMeansNull

parent ae615043
......@@ -2226,6 +2226,7 @@ See also at specific *FormElement* definitions.
| retypeNote | string | |
| characterCountWrap | string | |
| hideZero | string | |
| emptyMeansNull | string | |
+------------------------+--------+----------------------------------------------------------------------------------------------------------+
| typeAheadLimit | string | See `input-typeahead`_ |
| typeAheadMinLength | string | |
......@@ -2533,6 +2534,8 @@ Type: text
`text1` / `text2` is missing, just display `<current>/</max>`. Customization: `characterCountWrap=<div class=qfq-cc-style>Count: |</div>`
* Also check the :ref:`fe-parameter-attributes` *data-...-error* to customize error messages shown by the validator.
* *hideZero* = 0|1 (optional): `with hideZero=1` a '0' in the value will be replaced by an empty string.
* *emptyMeansNull* = [0|1] (optional): with `emptyMeansNull` or `emptyMeansNull=1` a NULL value will be written if
the value is an empty string
.. _`input-typeahead`:
......@@ -3229,11 +3232,11 @@ missing definition means 'take the default'. E.g.:
+--------------------+------------------------------------------------+
| note | Bitte alle Vornamen erfassen |
+--------------------+------------------------------------------------+
| languageParameterA | | title=Firstname |
| | | note=Please all firstnames |
| languageParameterA | |title=Firstname |
| | |note=Please give all firstnames |
+--------------------+------------------------------------------------+
| languageParameterB | | title=Persona de entrada |
| | | note=Por favor, introduzca todos los nombres |
| languageParameterB | |title=Persona de entrada |
| | |note=Por favor, introduzca todos los nombres |
+--------------------+------------------------------------------------+
......
......@@ -896,6 +896,7 @@ const FE_CHECKBOX_UNCHECKED = 'unchecked';
const FE_RECORD_DESTINATION_TABLE = 'recordDestinationTable';
const FE_RECORD_SOURCE_TABLE = 'recordSourceTable';
const FE_TRANSLATE_ID_COLUMN = 'translateIdColumn';
const FE_EMPTY_MEANS_NULL = 'emptyMeansNull';
const FE_FLAG_ROW_OPEN_TAG = '_flagRowOpenTag'; // will be automatically computed during Formload: true | false
const FE_FLAG_ROW_CLOSE_TAG = '_flagRowCloseTag'; // will be automatically computed during Formload: true | false
......
......@@ -98,6 +98,19 @@ class Save {
return $formValues;
}
/**
* @param $feName
* @return bool
*/
private function isSetEmptyMeansNull($feName) {
$fe = OnArray::filter($this->feSpecNative, FE_NAME, $feName);
$flag = isset($fe[0][FE_EMPTY_MEANS_NULL]) && $fe[0][FE_EMPTY_MEANS_NULL] != '0';
return $flag;
}
/**
* Build an array of all values which should be saved. Values must exist as a 'form value' as well as a regular 'table column'.
*
......@@ -145,8 +158,14 @@ class Save {
$this->store->setVar(SYSTEM_FORM_ELEMENT, "Column: $column", STORE_SYSTEM);
Support::setIfNotSet($formValues, $column);
// Check if an empty string has to be converted to null.
if (isset($formValues[$column]) && $formValues[$column] == '' && $this->isSetEmptyMeansNull($column)) {
$formValues[$column] = null;
} else {
Support::setIfNotSet($formValues, $column);
}
$newValues[$column] = $formValues[$column];
}
if ($columnModified && !isset($newValues[COLUMN_MODIFIED])) {
......
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