BUG 7353 Dependent field initial values fixed

This commit is contained in:
Enrique Ponce De Leon
2011-08-19 11:43:18 -04:00
parent a8fdb30b42
commit 3e6162ecc1

View File

@@ -2661,6 +2661,7 @@ class XmlForm_Field_Dropdown extends XmlForm_Field {
$html .= '>'; $html .= '>';
$findValue = ''; $findValue = '';
$firstValue = ''; $firstValue = '';
$cont=0;
foreach ($this->option as $optValue => $optName ){ foreach ($this->option as $optValue => $optName ){
settype($optValue,'string'); settype($optValue,'string');
$html .= '<option value="'.$optValue.'" '.(($optValue === $value)? 'selected="selected"' : '').'>'.$optName.'</option>'; $html .= '<option value="'.$optValue.'" '.(($optValue === $value)? 'selected="selected"' : '').'>'.$optName.'</option>';
@@ -2669,6 +2670,7 @@ class XmlForm_Field_Dropdown extends XmlForm_Field {
$displayLabel = $optName; $displayLabel = $optName;
} }
if ($firstValue == '') $firstValue = $optValue; if ($firstValue == '') $firstValue = $optValue;
$cont++;
} }
foreach ($this->sqlOption as $optValue => $optName ){ foreach ($this->sqlOption as $optValue => $optName ){
settype($optValue,'string'); settype($optValue,'string');
@@ -2686,7 +2688,7 @@ class XmlForm_Field_Dropdown extends XmlForm_Field {
$html .= 'name="form' . $rowId . '[' . $this->name . ']" '; $html .= 'name="form' . $rowId . '[' . $this->name . ']" ';
$html .= 'value="'.(($findValue != '') ? $findValue : $firstValue).'" />'; $html .= 'value="'.(($findValue != '') ? $findValue : $firstValue).'" />';
} }
$this->selectedValue = ($findValue != '') ? $findValue : $firstValue; $this->selectedValue = ($findValue != '') ? $findValue : ($cont==0)? $firstValue : '';
}else{ //Render Field showing only value; }else{ //Render Field showing only value;
foreach ($this->option as $optValue => $optName) { foreach ($this->option as $optValue => $optName) {