1 | <?php |
||
15 | abstract class Field |
||
16 | { |
||
17 | use FieldHasUiModifiers; |
||
18 | |||
19 | /** |
||
20 | * @var string |
||
21 | */ |
||
22 | const TYPE = 'type'; |
||
23 | |||
24 | /** |
||
25 | * @var bool |
||
26 | */ |
||
27 | const MULTIPART = false; |
||
28 | |||
29 | /** |
||
30 | * @var CrudFields |
||
31 | */ |
||
32 | protected $fields; |
||
33 | |||
34 | /** |
||
35 | * @var string |
||
36 | */ |
||
37 | protected $identifier; |
||
38 | |||
39 | /** |
||
40 | * @var array |
||
41 | */ |
||
42 | protected $rules; |
||
43 | |||
44 | /** |
||
45 | * Field constructor. |
||
46 | * |
||
47 | * @param string $identifier |
||
48 | * @param array|string $rules |
||
49 | */ |
||
50 | public function __construct($identifier, $rules = null) |
||
59 | |||
60 | /** |
||
61 | * Constructs staticly. |
||
62 | * |
||
63 | * @param string $idenfitier |
||
64 | * @param null|string|array $rules |
||
65 | * @return static |
||
66 | */ |
||
67 | public static function handle($idenfitier, $rules = null) |
||
71 | |||
72 | |||
73 | /** |
||
74 | * Add validation rules to the field. |
||
75 | * |
||
76 | * @param string|array $rules |
||
77 | * @return mixed |
||
78 | */ |
||
79 | public function withRules($rules) |
||
105 | |||
106 | /** |
||
107 | * Add a validation rule. |
||
108 | * |
||
109 | * @param string $rule |
||
110 | * @return self |
||
111 | */ |
||
112 | public function addRule($rule) |
||
118 | |||
119 | /** |
||
120 | * @param CrudFields $fields |
||
121 | * @return self |
||
122 | */ |
||
123 | public function setFields(CrudFields $fields) |
||
129 | |||
130 | /** |
||
131 | * Get the field identifier. |
||
132 | * |
||
133 | * @param void |
||
134 | * @return string |
||
135 | */ |
||
136 | public function getIdentifier() |
||
140 | |||
141 | /** |
||
142 | * Render the field form. |
||
143 | * |
||
144 | * @param void |
||
145 | * @return string |
||
146 | */ |
||
147 | public function form() |
||
151 | |||
152 | /** |
||
153 | * Get the form view. |
||
154 | * |
||
155 | * @param void |
||
156 | * @return View |
||
157 | */ |
||
158 | protected function getForm() |
||
162 | |||
163 | /** |
||
164 | * Get the field view name. |
||
165 | * |
||
166 | * @param void |
||
167 | * @return string |
||
168 | */ |
||
169 | abstract public function getViewName(); |
||
170 | |||
171 | /** |
||
172 | * Returns additionnal variables to the views. |
||
173 | * |
||
174 | * @param void |
||
175 | * @return array |
||
176 | */ |
||
177 | protected function getViewVariables() |
||
181 | |||
182 | /** |
||
183 | * Returns all base variables for the view. |
||
184 | * |
||
185 | * @param void |
||
186 | * @return array |
||
187 | */ |
||
188 | protected function getViewBaseVariables() |
||
206 | |||
207 | /** |
||
208 | * Checks if the field has an error. |
||
209 | * |
||
210 | * @param void |
||
211 | * @return bool |
||
212 | */ |
||
213 | public function hasError() |
||
217 | |||
218 | /** |
||
219 | * Returns the error. |
||
220 | * |
||
221 | * @param void |
||
222 | * @return null|string |
||
223 | */ |
||
224 | public function getError() |
||
233 | |||
234 | /** |
||
235 | * Checks if the field has a previous value. |
||
236 | * |
||
237 | * @param void |
||
238 | * @return bool |
||
239 | */ |
||
240 | public function hasOld() |
||
244 | |||
245 | /** |
||
246 | * Returns the old value. |
||
247 | * |
||
248 | * @param void |
||
249 | * @return string|null |
||
250 | */ |
||
251 | public function getOld() |
||
260 | |||
261 | /** |
||
262 | * Get the field value. |
||
263 | * |
||
264 | * @param void |
||
265 | * @return mixed |
||
266 | */ |
||
267 | public function getValue() |
||
276 | |||
277 | /** |
||
278 | * Get the value to be displayed on a table. |
||
279 | * |
||
280 | * @param void |
||
281 | * @return mixed |
||
282 | */ |
||
283 | public function getTableValue() |
||
287 | |||
288 | /** |
||
289 | * Set a new value to the model. |
||
290 | * |
||
291 | * @param mixed $value |
||
292 | * @return self |
||
293 | */ |
||
294 | public function newValue($value) |
||
303 | |||
304 | /** |
||
305 | * @param void |
||
306 | * @return string |
||
307 | */ |
||
308 | public function getRules() |
||
312 | |||
313 | /** |
||
314 | * @param Validator $validator |
||
315 | * @return Validator |
||
316 | */ |
||
317 | public function beforeValidation(Validator $validator) |
||
321 | } |
||
322 |
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: