Bug:ListBoxField and DropdownField does not respect getSource in all Places

In some places source is referenced directly and assumed to be array, while in some places the getSource() method is used instead.
By changing this you have more freedom when extending these classes
This commit is contained in:
Tom 2012-09-14 15:33:59 +03:00
parent bbb0868227
commit 54d8abcdc7
2 changed files with 2 additions and 2 deletions

View File

@ -236,7 +236,7 @@ class DropdownField extends FormField {
} }
function performReadonlyTransformation() { function performReadonlyTransformation() {
$field = new LookupField($this->name, $this->title, $this->source); $field = new LookupField($this->name, $this->title, $this->getSource());
$field->setValue($this->value); $field->setValue($this->value);
$field->setForm($this->form); $field->setForm($this->form);
$field->setReadonly(true); $field->setReadonly(true);

View File

@ -224,7 +224,7 @@ class ListboxField extends DropdownField {
// They're silently ignored and overwritten the next time the field is saved. // They're silently ignored and overwritten the next time the field is saved.
parent::setValue($parts); parent::setValue($parts);
} else { } else {
if(!in_array($val, array_keys($this->source))) { if(!in_array($val, array_keys($this->getSource()))) {
throw new InvalidArgumentException(sprintf( throw new InvalidArgumentException(sprintf(
'Invalid value "%s" for multiple=false', 'Invalid value "%s" for multiple=false',
Convert::raw2xml($val) Convert::raw2xml($val)