1 | <?php |
||
11 | class DropdownElement extends InputElement { |
||
12 | |||
13 | protected $options = array(); |
||
14 | |||
15 | protected $value = ''; |
||
16 | |||
17 | /** |
||
18 | * @param string $name The name of this form element |
||
19 | * @param string $options The available options |
||
20 | * @param string $label The label text for this element (will be autoescaped) |
||
21 | */ |
||
22 | public function __construct($name, $options, $label = '') { |
||
26 | |||
27 | /** |
||
28 | * Get or set the options of the Dropdown |
||
29 | * |
||
30 | * Options can be given as associative array (value => label) or as an |
||
31 | * indexd array (label = value) or as an array of arrays. In the latter |
||
32 | * case an element has to look as follows: |
||
33 | * option-value => array ( |
||
34 | * 'label' => option-label, |
||
35 | * 'attrs' => array ( |
||
36 | * attr-key => attr-value, ... |
||
37 | * ) |
||
38 | * ) |
||
39 | * |
||
40 | * @param null|array $options |
||
41 | * @return $this|array |
||
42 | */ |
||
43 | public function options($options = null) { |
||
61 | |||
62 | /** |
||
63 | * Gets or sets an attribute |
||
64 | * |
||
65 | * When no $value is given, the current content of the attribute is returned. |
||
66 | * An empty string is returned for unset attributes. |
||
67 | * |
||
68 | * When a $value is given, the content is set to that value and the Element |
||
69 | * itself is returned for easy chaining |
||
70 | * |
||
71 | * @param string $name Name of the attribute to access |
||
72 | * @param null|string $value New value to set |
||
73 | * @return string|$this |
||
74 | */ |
||
75 | public function attr($name, $value = null) { |
||
81 | |||
82 | /** |
||
83 | * Get or set the current value |
||
84 | * |
||
85 | * When setting a value that is not defined in the options, the value is ignored |
||
86 | * and the first option's value is selected instead |
||
87 | * |
||
88 | * @param null|string $value The value to set |
||
89 | * @return $this|string |
||
90 | */ |
||
91 | public function val($value = null) { |
||
104 | |||
105 | /** |
||
106 | * Create the HTML for the select it self |
||
107 | * |
||
108 | * @return string |
||
109 | */ |
||
110 | protected function mainElementHTML() { |
||
127 | |||
128 | } |
||
129 |
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: