Added the option to use advance field modeling to store data in other tables in combination with the field being set to not be stored in the view/table in the admin view. Fixed gh-487 yet once again to allow the datalength to be stored everytime, and not get dropped. Imporved the JCB way of conditions field behavior.
This commit is contained in:
@ -2987,7 +2987,9 @@ class Fields extends Structure
|
||||
$this->checkboxBuilder[$view_name_single][] = $name;
|
||||
}
|
||||
// setup checkboxes and other json items for this view
|
||||
if ($dbSwitch && (($typeName === 'subform' || $typeName === 'checkboxes' || $multiple || $field['settings']->store != 0) && $typeName != 'tag'))
|
||||
// if we have advance field modeling and the field is not being set in the DB
|
||||
// this could mean that field is modeled manually (so we add it)
|
||||
if (($dbSwitch || $field['settings']->store == 6) && (($typeName === 'subform' || $typeName === 'checkboxes' || $multiple || $field['settings']->store != 0) && $typeName != 'tag'))
|
||||
{
|
||||
$subformJsonSwitch = true;
|
||||
switch ($field['settings']->store)
|
||||
@ -3069,8 +3071,8 @@ class Fields extends Structure
|
||||
}
|
||||
}
|
||||
|
||||
// subform house keeping
|
||||
if ('subform' === $typeName)
|
||||
// subform house keeping (only if not advance modeling)
|
||||
if ('subform' === $typeName && $field['settings']->store != 6)
|
||||
{
|
||||
// the values must revert to array
|
||||
$this->jsonItemBuilderArray[$view_name_single][] = $name;
|
||||
|
@ -10091,29 +10091,41 @@ class Interpretation extends Fields
|
||||
// add the needed validation to file
|
||||
if (isset($this->validationFixBuilder[$viewName]) && ComponentbuilderHelper::checkArray($this->validationFixBuilder[$viewName]))
|
||||
{
|
||||
$validation .= PHP_EOL . "// update required fields";
|
||||
$validation .= PHP_EOL . "function updateFieldRequired(name,status)";
|
||||
$validation .= PHP_EOL . "{";
|
||||
$validation .= PHP_EOL . $this->_t(1) . "var not_required = jQuery('#jform_not_required').val();";
|
||||
$validation .= PHP_EOL . PHP_EOL . $this->_t(1) . "if(status == 1)";
|
||||
$validation .= PHP_EOL . $this->_t(1) . "{";
|
||||
$validation .= PHP_EOL . $this->_t(2) . "if (isSet(not_required) && not_required != 0)";
|
||||
$validation .= PHP_EOL . "// update fields required";
|
||||
$validation .= PHP_EOL . "function updateFieldRequired(name, status) {";
|
||||
$validation .= PHP_EOL . $this->_t(1) . "// check if not_required exist";
|
||||
$validation .= PHP_EOL . $this->_t(1) . "if (jQuery('#jform_not_required').length > 0) {";
|
||||
$validation .= PHP_EOL . $this->_t(2) . "var not_required = jQuery('#jform_not_required').val().split(\",\");";
|
||||
$validation .= PHP_EOL . PHP_EOL . $this->_t(2) . "if(status == 1)";
|
||||
$validation .= PHP_EOL . $this->_t(2) . "{";
|
||||
$validation .= PHP_EOL . $this->_t(3) . "not_required = not_required+','+name;";
|
||||
$validation .= PHP_EOL . $this->_t(3) . "not_required.push(name);";
|
||||
$validation .= PHP_EOL . $this->_t(2) . "}";
|
||||
$validation .= PHP_EOL . $this->_t(2) . "else";
|
||||
$validation .= PHP_EOL . $this->_t(2) . "{";
|
||||
$validation .= PHP_EOL . $this->_t(3) . "not_required = ','+name;";
|
||||
$validation .= PHP_EOL . $this->_t(3) . "not_required = removeFieldFromNotRequired(not_required, name);";
|
||||
$validation .= PHP_EOL . $this->_t(2) . "}";
|
||||
$validation .= PHP_EOL . PHP_EOL . $this->_t(2) . "jQuery('#jform_not_required').val(fixNotRequiredArray(not_required).toString());";
|
||||
$validation .= PHP_EOL . $this->_t(1) . "}";
|
||||
$validation .= PHP_EOL . $this->_t(1) . "else";
|
||||
$validation .= PHP_EOL . $this->_t(1) . "{";
|
||||
$validation .= PHP_EOL . $this->_t(2) . "if (isSet(not_required) && not_required != 0)";
|
||||
$validation .= PHP_EOL . $this->_t(2) . "{";
|
||||
$validation .= PHP_EOL . $this->_t(3) . "not_required = not_required.replace(','+name,'');";
|
||||
$validation .= PHP_EOL . $this->_t(2) . "}";
|
||||
$validation .= PHP_EOL . $this->_t(1) . "}";
|
||||
$validation .= PHP_EOL . PHP_EOL . $this->_t(1) . "jQuery('#jform_not_required').val(not_required);";
|
||||
$validation .= PHP_EOL . "}" . PHP_EOL;
|
||||
$validation .= PHP_EOL . "// remove field from not_required";
|
||||
$validation .= PHP_EOL . "function removeFieldFromNotRequired(array, what) {";
|
||||
$validation .= PHP_EOL . $this->_t(1) . "return array.filter(function(element){";
|
||||
$validation .= PHP_EOL . $this->_t(2) . "return element !== what;";
|
||||
$validation .= PHP_EOL . $this->_t(1) . "});";
|
||||
$validation .= PHP_EOL . "}" . PHP_EOL;
|
||||
$validation .= PHP_EOL . "// fix not required array";
|
||||
$validation .= PHP_EOL . "function fixNotRequiredArray(array) {";
|
||||
$validation .= PHP_EOL . $this->_t(1) . "var seen = {};";
|
||||
$validation .= PHP_EOL . $this->_t(1) . "return removeEmptyFromNotRequiredArray(array).filter(function(item) {";
|
||||
$validation .= PHP_EOL . $this->_t(2) . "return seen.hasOwnProperty(item) ? false : (seen[item] = true);";
|
||||
$validation .= PHP_EOL . $this->_t(1) . "});";
|
||||
$validation .= PHP_EOL . "}" . PHP_EOL;
|
||||
$validation .= PHP_EOL . "// remove empty from not_required array";
|
||||
$validation .= PHP_EOL . "function removeEmptyFromNotRequiredArray(array) {";
|
||||
$validation .= PHP_EOL . $this->_t(1) . "return array.filter(function (el) {";
|
||||
$validation .= PHP_EOL . $this->_t(2) . "// remove ( 一_一) as well - lol";
|
||||
$validation .= PHP_EOL . $this->_t(2) . "return (el.length > 0 && '一_一' !== el);";
|
||||
$validation .= PHP_EOL . $this->_t(1) . "});";
|
||||
$validation .= PHP_EOL . "}" . PHP_EOL;
|
||||
}
|
||||
// set the isSet function
|
||||
|
Reference in New Issue
Block a user