From 58d3b70fb4438bc6faeb3fef272adea85bcb3409 Mon Sep 17 00:00:00 2001 From: Victor Saisa Lopez Date: Tue, 29 Jan 2013 13:04:30 -0400 Subject: [PATCH] BUG 0000 "Problem in dependent fields with suggest field in grids" SOLVED - Problem in xmlform of grid type, when require fields of the main xmlform - Solved problem, added fields of the main xmlform * Available from version ProcessMaker-2.0.46 --- gulliver/system/class.xmlform.php | 27 ++++++++++++++++++++++----- 1 file changed, 22 insertions(+), 5 deletions(-) diff --git a/gulliver/system/class.xmlform.php b/gulliver/system/class.xmlform.php index 9a5608e39..9b2afc193 100755 --- a/gulliver/system/class.xmlform.php +++ b/gulliver/system/class.xmlform.php @@ -4037,19 +4037,36 @@ class XmlForm_Field_Grid extends XmlForm_Field //if ($therow == 1)g::pr($values); $this->rows = count( reset( $values ) ); + //Fields required in grid (view in sql attribute) + $arrayField = array(); + $arrayFieldRequired = array(); + + foreach ($this->fields as $index1 => $value1) { + $field = $value1; + + $arrayField[] = $field->name; + + preg_match_all("/@[@%#\?\$\=]([A-Za-z_]\w*)/", $field->sql, $arrayMatch, PREG_SET_ORDER); + + foreach ($arrayMatch as $value2) { + $arrayFieldRequired[] = $value2[1]; + } + } + + $arrayFieldRequired = array_unique($arrayFieldRequired); + $arrayFieldRequired = array_diff($arrayFieldRequired, $arrayField); + //Fields Grid only required fields of the grid, no all fields of dynaform main - /* - if (isset( $owner->values )) { + if (isset($owner->values) && count($arrayFieldRequired) > 0) { foreach ($owner->values as $key => $value) { - if (! isset( $values[$key] )) { - $values[$key] = array (); + if (in_array($key, $arrayFieldRequired) && !isset($values[$key])) { + $values[$key] = array(); //for($r=0; $r < $this->rows ; $r++ ) { $values[$key] = $value; //} } } } - */ foreach ($this->fields as $k => $v) { if (isset( $values['SYS_GRID_AGGREGATE_' . $this->name . '_' . $k] )) {