From 13abb80e69fac9a4e7c91a131ca6583107fe29af Mon Sep 17 00:00:00 2001 From: Julio Cesar Laura Date: Wed, 21 May 2014 16:39:48 -0400 Subject: [PATCH] BUG 12395 History log no refleja verdaderos datos historicos SOLVED - El engine de formularios no mostraba ningun valor para valores previamente almacenados que ya no tengan esa opcion en el control - Para el modo VISTA de los campos de tipo DROPDOWN, LISTBOX, RADIOGROUP y CHECKGROUP ahora se muestran los valores que se guardaron previamente, aunque el valor ya no exista en la definicion del control, ya sea que sus opciones sean agregadas manualmente o bien sean obtenidas por un SQL --- gulliver/system/class.xmlform.php | 61 +++++++++++++++++++++---------- 1 file changed, 41 insertions(+), 20 deletions(-) diff --git a/gulliver/system/class.xmlform.php b/gulliver/system/class.xmlform.php index 172ae9bde..dd1825630 100755 --- a/gulliver/system/class.xmlform.php +++ b/gulliver/system/class.xmlform.php @@ -3643,7 +3643,11 @@ class XmlForm_Field_Dropdown extends XmlForm_Field $html .= $this->renderHint(); } if ($displayStyle != '') { - $html = $displayLabel . $html; + if ($value === $findValue) { + $html = $displayLabel . $html; + } else { + $html = $value . $html; + } } return $html; } @@ -3691,12 +3695,6 @@ class XmlForm_Field_Listbox extends XmlForm_Field public $sql = ''; public $sqlOption = array (); - public function validateValue ($value, $owner) - { - $this->executeSQL( $owner ); - return true; // isset($value) && ( array_key_exists( $value , $this->options ) ); - } - /** * Function render * @@ -3741,13 +3739,26 @@ class XmlForm_Field_Listbox extends XmlForm_Field $html .= $this->renderHint(); return $html; } elseif ($this->mode === 'view') { + $valuesFound = array(); $html = ''; foreach ($this->option as $optionName => $option) { $html .= "name . "]\" name=\"form[" . $this->name . "][]\" value=\"" . ((in_array( $optionName . "", $value )) ? $optionName : "__NULL__") . "\">"; @@ -3755,6 +3766,12 @@ class XmlForm_Field_Listbox extends XmlForm_Field foreach ($this->sqlOption as $optionName => $option) { $html .= "name . "]\" name=\"form[" . $this->name . "][]\" value=\"" . ((in_array( $optionName . "", $value )) ? $optionName : "__NULL__") . "\">"; } + if (count($valuesFound) < count($value)) { + $valuesNotFound = array_diff($value, $valuesFound); + foreach ($valuesNotFound as $option) { + $html .= "name . "]\" name=\"form[" . $this->name . "][]\" value=\"" . $option . "\">"; + } + } return $html; } else { return $this->htmlentities( $value, ENT_COMPAT, 'utf-8' ); @@ -3792,19 +3809,6 @@ class XmlForm_Field_RadioGroup extends XmlForm_Field public $viewAlign = 'vertical'; public $linkType; - /** - * validate the execution of a query - * - * @param $value - * @param $owner - * @return $value - */ - public function validateValue ($value, $owner) - { - $this->executeSQL( $owner ); - return isset( $value ) && (array_key_exists( $value, $this->options )); - } - /** * Function render * @@ -3842,12 +3846,18 @@ class XmlForm_Field_RadioGroup extends XmlForm_Field return $html; } elseif ($this->mode === 'view') { $html = ''; + $existsValue = false; foreach ($this->options as $optionName => $option) { $html .= 'NSFieldType() . ' name="form[' . $this->name . ']" type=\'radio\' value="' . $optionName . '" ' . (($optionName == $value) ? 'checked' : '') . ' disabled>
'; if ($optionName == $value) { + $existsValue = true; $html .= ''; } } + if (!$existsValue && $value !== '') { + $html .= 'NSFieldType() . ' name="form[' . $this->name . ']" type=\'radio\' value="' . $value . '" checked disabled>
'; + $html .= ''; + } return $html; } else { return $this->htmlentities( $value, ENT_COMPAT, 'utf-8' ); @@ -3949,11 +3959,22 @@ class XmlForm_Field_CheckGroup extends XmlForm_Field } //fin for return $html; } elseif ($this->mode === 'view') { + $valuesFound = array(); $html = ''; foreach ($this->options as $optionName => $option) { + if (in_array( $optionName . "", $value )) { + $valuesFound[] = $optionName . ""; + } $html .= "NSFieldType() . "class=\"FormCheck\" type=\"checkbox\" id=\"form[" . $this->name . "][" . $optionName . "]\" value=\"" . $optionName . "\"" . (in_array( $optionName . "", $value ) ? " checked=\"checked\" " : "") . " disabled=\"disabled\">
"; $html .= "name . "][]\" value=\"" . ((in_array( $optionName . "", $value )) ? $optionName : "__NULL__") . "\">"; } + if (count($valuesFound) < count($value)) { + $valuesNotFound = array_diff($value, $valuesFound); + foreach ($valuesNotFound as $option) { + $html .= "NSFieldType() . "class=\"FormCheck\" type=\"checkbox\" id=\"form[" . $this->name . "][" . $option . "]\" value=\"" . $option . "\" checked=\"checked\" disabled=\"disabled\">
"; + $html .= "name . "][]\" value=\"" . $option . "\">"; + } + } return $html; } else { return $this->htmlentities( $value, ENT_COMPAT, 'utf-8' );