1 | <?php |
||
56 | class GroupedDropdownField extends DropdownField { |
||
57 | |||
58 | public function Field($properties = array()) { |
||
59 | $options = ''; |
||
60 | foreach($this->getSource() as $value => $title) { |
||
61 | if(is_array($title)) { |
||
62 | $options .= "<optgroup label=\"$value\">"; |
||
63 | foreach($title as $value2 => $title2) { |
||
64 | $disabled = ''; |
||
65 | if( array_key_exists($value, $this->disabledItems) |
||
66 | && is_array($this->disabledItems[$value]) |
||
67 | && in_array($value2, $this->disabledItems[$value]) ){ |
||
68 | $disabled = 'disabled="disabled"'; |
||
69 | } |
||
70 | $selected = $value2 == $this->value ? " selected=\"selected\"" : ""; |
||
71 | $options .= "<option$selected value=\"$value2\" $disabled>$title2</option>"; |
||
72 | } |
||
73 | $options .= "</optgroup>"; |
||
74 | } else { // Fall back to the standard dropdown field |
||
75 | $disabled = ''; |
||
76 | if( in_array($value, $this->disabledItems) ){ |
||
77 | $disabled = 'disabled="disabled"'; |
||
78 | } |
||
79 | $selected = $value == $this->value ? " selected=\"selected\"" : ""; |
||
80 | $options .= "<option$selected value=\"$value\" $disabled>$title</option>"; |
||
81 | } |
||
82 | } |
||
83 | |||
84 | return FormField::create_tag('select', $this->getAttributes(), $options); |
||
85 | } |
||
86 | |||
87 | public function Type() { |
||
90 | |||
91 | /** |
||
92 | * Validate this field |
||
93 | * |
||
94 | * @param Validator $validator |
||
95 | * @return bool |
||
96 | */ |
||
97 | public function validate($validator) { |
||
133 | |||
134 | } |
||
135 |
It seems like the type of the argument is not accepted by the function/method which you are calling.
In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.
We suggest to add an explicit type cast like in the following example: