This commit is contained in:
Roly Rudy Gutierrez Pinto
2017-11-29 11:51:24 -04:00
parent 7eaad8c063
commit 238e80c82b

View File

@@ -3,6 +3,7 @@
use ProcessMaker\Core\System; use ProcessMaker\Core\System;
use ProcessMaker\BusinessModel\DynaForm\SuggestTrait; use ProcessMaker\BusinessModel\DynaForm\SuggestTrait;
use ProcessMaker\BusinessModel\Cases; use ProcessMaker\BusinessModel\Cases;
use ProcessMaker\BusinessModel\DynaForm\ValidatorFactory;
/** /**
* Implementing pmDynaform library in the running case. * Implementing pmDynaform library in the running case.
@@ -1893,39 +1894,23 @@ class PmDynaform
$previusFunction = $this->onPropertyRead; $previusFunction = $this->onPropertyRead;
$this->onPropertyRead = function($json, $key, $value) use (&$post) { $this->onPropertyRead = function($json, $key, $value) use (&$post) {
if ($key === "type" && isset($json->variable) && !empty($json->variable)) { if ($key === "type" && isset($json->variable) && !empty($json->variable)) {
//Clears the data in the appData for grids //clears the data in the appData for grids
if ($json->type === 'grid' && $isThereIdIntoPost = array_key_exists($json->id, $post);
array_key_exists($json->id, $this->fields) && $isThereIdIntoFields = array_key_exists($json->id, $this->fields);
!array_key_exists($json->id, $post) if ($json->type === 'grid' && !$isThereIdIntoPost && $isThereIdIntoFields) {
) {
$post[$json->variable] = [[]]; $post[$json->variable] = [[]];
} }
//validate 'protectedValue' property //validate 'protectedValue' property
if (isset($json->protectedValue) && $json->protectedValue === true) { if (isset($json->protectedValue) && $json->protectedValue === true) {
if (isset($post[$json->variable])) { if (isset($this->fields[$json->variable])) {
unset($post[$json->variable]); $post[$json->variable] = $this->fields[$json->variable];
} }
if (isset($post[$json->variable . "_label"])) { if (isset($this->fields[$json->variable . "_label"])) {
unset($post[$json->variable . "_label"]); $post[$json->variable . "_label"] = $this->fields[$json->variable . "_label"];
}
}
if ($json->type === "grid" && is_array($json->columns)) {
foreach ($json->columns as $column) {
if (isset($column->protectedValue) && $column->protectedValue === true) {
$dataGrid = is_array($post[$json->variable]) ? $post[$json->variable] : array();
foreach ($dataGrid as $keyRow => $row) {
if (isset($post[$json->variable][$keyRow][$column->id])) {
unset($post[$json->variable][$keyRow][$column->id]);
}
if (isset($post[$json->variable][$keyRow][$column->id . "_label"])) {
unset($post[$json->variable][$keyRow][$column->id . "_label"]);
}
}
}
} }
} }
//validator data //validator data
$validatorClass = ProcessMaker\BusinessModel\DynaForm\ValidatorFactory::createValidatorClass($json->type, $json); $validatorClass = ValidatorFactory::createValidatorClass($json->type, $json);
if ($validatorClass !== null) { if ($validatorClass !== null) {
$validatorClass->validatePost($post); $validatorClass->validatePost($post);
} }