1 | <?php |
||
49 | class Form implements Renderable |
||
50 | { |
||
51 | /** |
||
52 | * @var Field[] |
||
53 | */ |
||
54 | protected $fields = []; |
||
55 | |||
56 | /** |
||
57 | * @var array |
||
58 | */ |
||
59 | protected $data = []; |
||
60 | |||
61 | /** |
||
62 | * @var array |
||
63 | */ |
||
64 | protected $attributes = []; |
||
65 | |||
66 | /** |
||
67 | * Available buttons. |
||
68 | * |
||
69 | * @var array |
||
70 | */ |
||
71 | protected $buttons = ['reset', 'submit']; |
||
72 | |||
73 | /** |
||
74 | * Form constructor. |
||
75 | * |
||
76 | * @param array $data |
||
77 | */ |
||
78 | public function __construct($data = []) |
||
90 | |||
91 | /** |
||
92 | * Initialize the form attributes. |
||
93 | */ |
||
94 | protected function initFormAttributes() |
||
104 | |||
105 | /** |
||
106 | * Action uri of the form. |
||
107 | * |
||
108 | * @param string $action |
||
109 | * |
||
110 | * @return $this |
||
111 | */ |
||
112 | public function action($action) |
||
116 | |||
117 | /** |
||
118 | * Method of the form. |
||
119 | * |
||
120 | * @param string $method |
||
121 | * |
||
122 | * @return $this |
||
123 | */ |
||
124 | public function method($method = 'POST') |
||
128 | |||
129 | /** |
||
130 | * Add form attributes. |
||
131 | * |
||
132 | * @param string|array $attr |
||
133 | * @param string $value |
||
134 | * |
||
135 | * @return $this |
||
136 | */ |
||
137 | public function attribute($attr, $value = '') |
||
149 | |||
150 | /** |
||
151 | * Disable Pjax. |
||
152 | * |
||
153 | * @return $this |
||
154 | */ |
||
155 | public function disablePjax() |
||
161 | |||
162 | /** |
||
163 | * Disable reset button. |
||
164 | * |
||
165 | * @return $this |
||
166 | */ |
||
167 | public function disableReset() |
||
173 | |||
174 | /** |
||
175 | * Disable submit button. |
||
176 | * |
||
177 | * @return $this |
||
178 | */ |
||
179 | public function disableSubmit() |
||
185 | |||
186 | /** |
||
187 | * Set field and label width in current form. |
||
188 | * |
||
189 | * @param int $fieldWidth |
||
190 | * @param int $labelWidth |
||
191 | * |
||
192 | * @return $this |
||
193 | */ |
||
194 | public function setWidth($fieldWidth = 8, $labelWidth = 2) |
||
203 | |||
204 | /** |
||
205 | * Find field class with given name. |
||
206 | * |
||
207 | * @param string $method |
||
208 | * |
||
209 | * @return bool|string |
||
210 | */ |
||
211 | public static function findFieldClass($method) |
||
212 | { |
||
213 | $class = array_get(\Encore\Admin\Form::$availableFields, $method); |
||
214 | |||
215 | if (class_exists($class)) { |
||
216 | return $class; |
||
217 | } |
||
218 | |||
219 | return false; |
||
220 | } |
||
221 | |||
222 | /** |
||
223 | * Add a form field to form. |
||
224 | * |
||
225 | * @param Field $field |
||
226 | * |
||
227 | * @return $this |
||
228 | */ |
||
229 | public function pushField(Field &$field) |
||
235 | |||
236 | /** |
||
237 | * Get variables for render form. |
||
238 | * |
||
239 | * @return array |
||
240 | */ |
||
241 | protected function getVariables() |
||
254 | |||
255 | /** |
||
256 | * Format form attributes form array to html. |
||
257 | * |
||
258 | * @param array $attributes |
||
259 | * |
||
260 | * @return string |
||
261 | */ |
||
262 | public function formatAttribute($attributes = []) |
||
282 | |||
283 | /** |
||
284 | * Determine if form fields has files. |
||
285 | * |
||
286 | * @return bool |
||
287 | */ |
||
288 | public function hasFile() |
||
298 | |||
299 | /** |
||
300 | * Generate a Field object and add to form builder if Field exists. |
||
301 | * |
||
302 | * @param string $method |
||
303 | * @param array $arguments |
||
304 | * |
||
305 | * @return Field|null |
||
306 | */ |
||
307 | public function __call($method, $arguments) |
||
319 | |||
320 | /** |
||
321 | * Render the form. |
||
322 | * |
||
323 | * @return string |
||
324 | */ |
||
325 | public function render() |
||
329 | |||
330 | /** |
||
331 | * Output as string. |
||
332 | * |
||
333 | * @return string |
||
334 | */ |
||
335 | public function __toString() |
||
339 | } |
||
340 |
It seems like the method you are trying to call exists only in some of the possible types.
Let’s take a look at an example:
Available Fixes
Add an additional type-check:
Only allow a single type to be passed if the variable comes from a parameter: