SF Bug #3294924 - Template Selects dosen't work properly

This commit is contained in:
Deon George 2011-05-01 11:39:54 +10:00
parent 6eb6641454
commit 3919825000
3 changed files with 23 additions and 6 deletions

View File

@ -778,7 +778,20 @@ class Attribute {
case 'value':
if (is_array($value))
$this->values = $value;
foreach ($value as $y) {
if (! $this->haveMoreValues()) {
system_message(array(
'title'=>_('Automatically removed attribute values from template'),
'body'=>sprintf('%s <small>[%s]</small>',_('Template defines more values than can be accepted by attribute.'),$this->getName(true)),
'type'=>'warn'));
$this->clearValue();
break;
} else
$this->addValue($y);
}
else
# Check to see if the value is auto generated.
@ -791,7 +804,7 @@ class Attribute {
$this->hint = _('Automatically determined');
} else
$this->values = array($value);
$this->addValue($value);
break;

View File

@ -1106,10 +1106,7 @@ class PageRender extends Visitor {
foreach ($attribute->getSelection() as $value => $description) {
printf('<option value="%s" %s>%s</option>',$value,
($value == $val) ? 'selected="selected"' : '',$description);
if ($value == $val)
$found = true;
((strcasecmp($value,$val) == 0) && $found = true) ? 'selected="selected"' : '',$description);
if ($value == '')
$empty_value = true;

View File

@ -37,6 +37,13 @@ class SelectionAttribute extends Attribute {
$this->selection[$value] = $description;
}
public function addValue($new_val,$i=-1) {
if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS'))
debug_log('Entered (%%)',5,0,__FILE__,__LINE__,__METHOD__,$fargs);
$this->addOption($new_val,$new_val);
}
public function getOptionCount() {
return count($this->selection);
}