Complex classes like Form often do a lot of different things. To break such a class down, we need to identify a cohesive component within that class. A common approach to find such a component is to look for fields/methods that share the same prefixes, or suffixes. You can also have a look at the cohesion graph to spot any un-connected, or weakly-connected components.
Once you have determined the fields that belong together, you can apply the Extract Class refactoring. If the component makes sense as a sub-class, Extract Subclass is also a candidate, and is often faster.
While breaking up the class, it is a good idea to analyze how other classes use Form, and based on these observations, apply Extract Interface, too.
1 | <?php |
||
17 | class Form |
||
18 | { |
||
19 | /** |
||
20 | * All fields that are added. |
||
21 | * |
||
22 | * @var array |
||
23 | */ |
||
24 | protected $fields = []; |
||
25 | |||
26 | /** |
||
27 | * Model to use. |
||
28 | * |
||
29 | * @var mixed |
||
30 | */ |
||
31 | protected $model = []; |
||
32 | |||
33 | /** |
||
34 | * @var EventDispatcher |
||
35 | */ |
||
36 | protected $eventDispatcher; |
||
37 | |||
38 | /** |
||
39 | * @var FormHelper |
||
40 | */ |
||
41 | protected $formHelper; |
||
42 | |||
43 | /** |
||
44 | * Form options. |
||
45 | * |
||
46 | * @var array |
||
47 | */ |
||
48 | protected $formOptions = [ |
||
49 | 'method' => 'GET', |
||
50 | 'url' => null, |
||
51 | 'attr' => [], |
||
52 | ]; |
||
53 | |||
54 | /** |
||
55 | * Form specific configuration. |
||
56 | * |
||
57 | * @var array |
||
58 | */ |
||
59 | protected $formConfig = []; |
||
60 | |||
61 | /** |
||
62 | * Additional data which can be used to build fields. |
||
63 | * |
||
64 | * @var array |
||
65 | */ |
||
66 | protected $data = []; |
||
67 | |||
68 | /** |
||
69 | * Wether errors for each field should be shown when calling form($form) or form_rest($form). |
||
70 | * |
||
71 | * @var bool |
||
72 | */ |
||
73 | protected $showFieldErrors = true; |
||
74 | |||
75 | /** |
||
76 | * Enable html5 validation. |
||
77 | * |
||
78 | * @var bool |
||
79 | */ |
||
80 | protected $clientValidationEnabled = true; |
||
81 | |||
82 | /** |
||
83 | * Name of the parent form if any. |
||
84 | * |
||
85 | * @var string|null |
||
86 | */ |
||
87 | protected $name = null; |
||
88 | |||
89 | /** |
||
90 | * @var FormBuilder |
||
91 | */ |
||
92 | protected $formBuilder; |
||
93 | |||
94 | /** |
||
95 | * @var ValidatorFactory |
||
96 | */ |
||
97 | protected $validatorFactory; |
||
98 | |||
99 | /** |
||
100 | * @var Validator |
||
101 | */ |
||
102 | protected $validator = null; |
||
103 | |||
104 | /** |
||
105 | * @var Request |
||
106 | */ |
||
107 | protected $request; |
||
108 | |||
109 | /** |
||
110 | * List of fields to not render. |
||
111 | * |
||
112 | * @var array |
||
113 | **/ |
||
114 | protected $exclude = []; |
||
115 | |||
116 | /** |
||
117 | * Wether the form is beign rebuild. |
||
118 | * |
||
119 | * @var bool |
||
120 | */ |
||
121 | protected $rebuilding = false; |
||
122 | |||
123 | /** |
||
124 | * @var string |
||
125 | */ |
||
126 | protected $templatePrefix; |
||
127 | |||
128 | /** |
||
129 | * @var string |
||
130 | */ |
||
131 | protected $languageName; |
||
132 | |||
133 | /** |
||
134 | * @var string |
||
135 | */ |
||
136 | protected $translationTemplate; |
||
137 | |||
138 | /** |
||
139 | * To filter and mutate request values or not. |
||
140 | * |
||
141 | * @var bool |
||
142 | */ |
||
143 | protected $lockFiltering = false; |
||
144 | |||
145 | /** |
||
146 | * Define the error bag name for the form. |
||
147 | * |
||
148 | * @var string |
||
149 | */ |
||
150 | protected $errorBag = 'default'; |
||
151 | |||
152 | /** |
||
153 | * Build the form. |
||
154 | * |
||
155 | * @return mixed |
||
156 | */ |
||
157 | 3 | public function buildForm() |
|
160 | |||
161 | /** |
||
162 | * Rebuild the form from scratch. |
||
163 | * |
||
164 | * @return $this |
||
165 | */ |
||
166 | 19 | public function rebuildForm() |
|
184 | |||
185 | /** |
||
186 | * Create the FormField object. |
||
187 | * |
||
188 | * @param string $name |
||
189 | * @param string $type |
||
190 | * @param array $options |
||
191 | * @return FormField |
||
192 | */ |
||
193 | 65 | protected function makeField($name, $type = 'text', array $options = []) |
|
207 | |||
208 | /** |
||
209 | * Create a new field and add it to the form. |
||
210 | * |
||
211 | * @param string $name |
||
212 | * @param string $type |
||
213 | * @param array $options |
||
214 | * @param bool $modify |
||
215 | * @return $this |
||
216 | */ |
||
217 | 67 | public function add($name, $type = 'text', array $options = [], $modify = false) |
|
229 | |||
230 | /** |
||
231 | * Add a FormField to the form's fields. |
||
232 | * |
||
233 | * @param FormField $field |
||
234 | * @return $this |
||
235 | */ |
||
236 | 61 | protected function addField(FormField $field, $modify = false) |
|
251 | |||
252 | /** |
||
253 | * Add field before another field. |
||
254 | * |
||
255 | * @param string $name Name of the field before which new field is added. |
||
256 | * @param string $fieldName Field name which will be added. |
||
257 | * @param string $type |
||
258 | * @param array $options |
||
259 | * @param bool $modify |
||
260 | * @return $this |
||
261 | */ |
||
262 | 1 | public function addBefore($name, $fieldName, $type = 'text', $options = [], $modify = false) |
|
277 | |||
278 | /** |
||
279 | * Add field before another field. |
||
280 | * |
||
281 | * @param string $name Name of the field after which new field is added. |
||
282 | * @param string $fieldName Field name which will be added. |
||
283 | * @param string $type |
||
284 | * @param array $options |
||
285 | * @param bool $modify |
||
286 | * @return $this |
||
287 | */ |
||
288 | 1 | public function addAfter($name, $fieldName, $type = 'text', $options = [], $modify = false) |
|
303 | |||
304 | /** |
||
305 | * Take another form and add it's fields directly to this form. |
||
306 | * |
||
307 | * @param mixed $class Form to merge. |
||
308 | * @param array $options |
||
309 | * @param boolean $modify |
||
310 | * @return $this |
||
311 | */ |
||
312 | 1 | public function compose($class, array $options = [], $modify = false) |
|
340 | |||
341 | /** |
||
342 | * Remove field with specified name from the form. |
||
343 | * |
||
344 | * @param string|string[] $names |
||
345 | * @return $this |
||
346 | */ |
||
347 | 2 | public function remove($names) |
|
357 | |||
358 | /** |
||
359 | * Modify existing field. If it doesn't exist, it is added to form. |
||
360 | * |
||
361 | * @param string $name |
||
362 | * @param string $type |
||
363 | * @param array $options |
||
364 | * @param bool $overwriteOptions |
||
365 | * @return Form |
||
366 | */ |
||
367 | 1 | public function modify($name, $type = 'text', array $options = [], $overwriteOptions = false) |
|
379 | |||
380 | /** |
||
381 | * Render full form. |
||
382 | * |
||
383 | * @param array $options |
||
384 | * @param bool $showStart |
||
385 | * @param bool $showFields |
||
386 | * @param bool $showEnd |
||
387 | * @return string |
||
388 | */ |
||
389 | 7 | public function renderForm(array $options = [], $showStart = true, $showFields = true, $showEnd = true) |
|
393 | |||
394 | /** |
||
395 | * Render rest of the form. |
||
396 | * |
||
397 | * @param bool $showFormEnd |
||
398 | * @param bool $showFields |
||
399 | * @return string |
||
400 | */ |
||
401 | 1 | public function renderRest($showFormEnd = true, $showFields = true) |
|
407 | |||
408 | /** |
||
409 | * Renders the rest of the form up until the specified field name. |
||
410 | * |
||
411 | * @param string $field_name |
||
412 | * @param bool $showFormEnd |
||
413 | * @param bool $showFields |
||
414 | * @return string |
||
415 | */ |
||
416 | 2 | public function renderUntil($field_name, $showFormEnd = true, $showFields = true) |
|
436 | |||
437 | /** |
||
438 | * Get single field instance from form object. |
||
439 | * |
||
440 | * @param string $name |
||
441 | * @return FormField |
||
442 | */ |
||
443 | 35 | public function getField($name) |
|
451 | |||
452 | 101 | public function getErrorBag() |
|
456 | |||
457 | /** |
||
458 | * Check if form has field. |
||
459 | * |
||
460 | * @param string $name |
||
461 | * @return bool |
||
462 | */ |
||
463 | 61 | public function has($name) |
|
467 | |||
468 | /** |
||
469 | * Get all form options. |
||
470 | * |
||
471 | * @return array |
||
472 | */ |
||
473 | 2 | public function getFormOptions() |
|
477 | |||
478 | /** |
||
479 | * Get single form option. |
||
480 | * |
||
481 | * @param string $option |
||
482 | * @param mixed|null $default |
||
483 | * @return mixed |
||
484 | */ |
||
485 | 129 | public function getFormOption($option, $default = null) |
|
489 | |||
490 | /** |
||
491 | * Set single form option on form. |
||
492 | * |
||
493 | * @param string $option |
||
494 | * @param mixed $value |
||
495 | * |
||
496 | * @return $this |
||
497 | */ |
||
498 | 2 | public function setFormOption($option, $value) |
|
504 | |||
505 | /** |
||
506 | * Get the passed config key using the custom |
||
507 | * form config, if any. |
||
508 | * |
||
509 | * @param string $key |
||
510 | * @param mixed $default |
||
511 | * |
||
512 | * @return mixed |
||
513 | */ |
||
514 | 103 | public function getConfig($key = null, $default = null) |
|
518 | |||
519 | /** |
||
520 | * Set form options. |
||
521 | * |
||
522 | * @param array $formOptions |
||
523 | * @return $this |
||
524 | */ |
||
525 | 129 | public function setFormOptions(array $formOptions) |
|
539 | |||
540 | /** |
||
541 | * Get an option from provided options and call method with that value. |
||
542 | * |
||
543 | * @param string $name |
||
544 | * @param string $method |
||
545 | */ |
||
546 | 129 | protected function pullFromOptions($name, $method) |
|
552 | |||
553 | /** |
||
554 | * Get form http method. |
||
555 | * |
||
556 | * @return string |
||
557 | */ |
||
558 | 3 | public function getMethod() |
|
562 | |||
563 | /** |
||
564 | * Set form http method. |
||
565 | * |
||
566 | * @param string $method |
||
567 | * @return $this |
||
568 | */ |
||
569 | 1 | public function setMethod($method) |
|
575 | |||
576 | /** |
||
577 | * Get form action url. |
||
578 | * |
||
579 | * @return string |
||
580 | */ |
||
581 | 3 | public function getUrl() |
|
585 | |||
586 | /** |
||
587 | * Set form action url. |
||
588 | * |
||
589 | * @param string $url |
||
590 | * @return $this |
||
591 | */ |
||
592 | 1 | public function setUrl($url) |
|
598 | |||
599 | /** |
||
600 | * Returns the name of the form. |
||
601 | * |
||
602 | * @return string|null |
||
603 | */ |
||
604 | 69 | public function getName() |
|
608 | |||
609 | /** |
||
610 | * Set the name of the form. |
||
611 | * |
||
612 | * @param string $name |
||
613 | * @param bool $rebuild |
||
614 | * @return $this |
||
615 | */ |
||
616 | 12 | public function setName($name, $rebuild = true) |
|
626 | |||
627 | /** |
||
628 | * Get model that is bind to form object. |
||
629 | * |
||
630 | * @return mixed |
||
631 | */ |
||
632 | 96 | public function getModel() |
|
636 | |||
637 | /** |
||
638 | * Set model to form object. |
||
639 | * |
||
640 | * @param mixed $model |
||
641 | * @return $this |
||
642 | * @deprecated deprecated since 1.6.31, will be removed in 1.7 - pass model as option when creating a form |
||
643 | */ |
||
644 | 17 | public function setModel($model) |
|
652 | |||
653 | /** |
||
654 | * Setup model for form, add namespace if needed for child forms. |
||
655 | * |
||
656 | * @return $this |
||
657 | */ |
||
658 | 12 | protected function setupModel($model) |
|
665 | |||
666 | /** |
||
667 | * Get all fields. |
||
668 | * |
||
669 | * @return FormField[] |
||
670 | */ |
||
671 | 129 | public function getFields() |
|
675 | |||
676 | /** |
||
677 | * Get field dynamically. |
||
678 | * |
||
679 | * @param string $name |
||
680 | * @return FormField |
||
681 | */ |
||
682 | 20 | public function __get($name) |
|
688 | |||
689 | /** |
||
690 | * Check if field exists when fetched using magic methods. |
||
691 | * |
||
692 | * @param string $name |
||
693 | * @return bool |
||
694 | */ |
||
695 | public function __isset($name) |
||
699 | |||
700 | /** |
||
701 | * Set the Event Dispatcher to fire Laravel events. |
||
702 | * |
||
703 | * @param EventDispatcher $eventDispatcher |
||
704 | * @return $this |
||
705 | */ |
||
706 | 129 | public function setEventDispatcher(EventDispatcher $eventDispatcher) |
|
712 | |||
713 | /** |
||
714 | * Set the form helper only on first instantiation. |
||
715 | * |
||
716 | * @param FormHelper $formHelper |
||
717 | * @return $this |
||
718 | */ |
||
719 | 129 | public function setFormHelper(FormHelper $formHelper) |
|
725 | |||
726 | /** |
||
727 | * Get form helper. |
||
728 | * |
||
729 | * @return FormHelper |
||
730 | */ |
||
731 | 101 | public function getFormHelper() |
|
735 | |||
736 | /** |
||
737 | * Add custom field. |
||
738 | * |
||
739 | * @param $name |
||
740 | * @param $class |
||
741 | */ |
||
742 | 2 | public function addCustomField($name, $class) |
|
750 | |||
751 | /** |
||
752 | * Returns wether form errors should be shown under every field. |
||
753 | * |
||
754 | * @return bool |
||
755 | */ |
||
756 | 101 | public function haveErrorsEnabled() |
|
760 | |||
761 | /** |
||
762 | * Enable or disable showing errors under fields |
||
763 | * |
||
764 | * @param bool $enabled |
||
765 | * @return $this |
||
766 | */ |
||
767 | 1 | public function setErrorsEnabled($enabled) |
|
773 | |||
774 | /** |
||
775 | * Is client validation enabled? |
||
776 | * |
||
777 | * @return bool |
||
778 | */ |
||
779 | 101 | public function clientValidationEnabled() |
|
783 | |||
784 | /** |
||
785 | * Enable/disable client validation. |
||
786 | * |
||
787 | * @param bool $enable |
||
788 | * @return $this |
||
789 | */ |
||
790 | 2 | public function setClientValidationEnabled($enable) |
|
796 | |||
797 | /** |
||
798 | * Add any aditional data that field needs (ex. array of choices). |
||
799 | * |
||
800 | * @deprecated deprecated since 1.6.20, will be removed in 1.7 - use 3rd param on create, or 2nd on plain method to pass data |
||
801 | * will be switched to protected in 1.7. |
||
802 | * @param string $name |
||
803 | * @param mixed $data |
||
804 | */ |
||
805 | 1 | public function setData($name, $data) |
|
809 | |||
810 | /** |
||
811 | * Get single additional data. |
||
812 | * |
||
813 | * @param string $name |
||
814 | * @param null $default |
||
815 | * @return mixed |
||
816 | */ |
||
817 | 20 | public function getData($name = null, $default = null) |
|
825 | |||
826 | /** |
||
827 | * Add multiple peices of data at once. |
||
828 | * |
||
829 | * @deprecated deprecated since 1.6.12, will be removed in 1.7 - use 3rd param on create, or 2nd on plain method to pass data |
||
830 | * will be switched to protected in 1.7. |
||
831 | * @param $data |
||
832 | * @return $this |
||
833 | **/ |
||
834 | 129 | public function addData(array $data) |
|
842 | |||
843 | /** |
||
844 | * Get current request. |
||
845 | * |
||
846 | * @return \Illuminate\Http\Request |
||
847 | */ |
||
848 | 101 | public function getRequest() |
|
852 | |||
853 | /** |
||
854 | * Set request on form. |
||
855 | * |
||
856 | * @param Request $request |
||
857 | * @return $this |
||
858 | */ |
||
859 | 129 | public function setRequest(Request $request) |
|
865 | |||
866 | /** |
||
867 | * Get template prefix that is prepended to all template paths. |
||
868 | * |
||
869 | * @return string |
||
870 | */ |
||
871 | 39 | public function getTemplatePrefix() |
|
879 | |||
880 | /** |
||
881 | * Set a template prefix for the form and its fields. |
||
882 | * |
||
883 | * @param string $prefix |
||
884 | * @return $this |
||
885 | */ |
||
886 | 4 | public function setTemplatePrefix($prefix) |
|
892 | |||
893 | /** |
||
894 | * Get the language name. |
||
895 | * |
||
896 | * @return string |
||
897 | */ |
||
898 | 98 | public function getLanguageName() |
|
902 | |||
903 | /** |
||
904 | * Set a language name, used as prefix for translated strings. |
||
905 | * |
||
906 | * @param string $prefix |
||
907 | * @return $this |
||
908 | */ |
||
909 | 13 | public function setLanguageName($prefix) |
|
915 | |||
916 | /** |
||
917 | * Get the translation template. |
||
918 | * |
||
919 | * @return string |
||
920 | */ |
||
921 | 100 | public function getTranslationTemplate() |
|
925 | |||
926 | /** |
||
927 | * Set a translation template, used to determine labels for fields. |
||
928 | * |
||
929 | * @param string $template |
||
930 | * @return $this |
||
931 | */ |
||
932 | 11 | public function setTranslationTemplate($template) |
|
938 | |||
939 | /** |
||
940 | * Render the form. |
||
941 | * |
||
942 | * @param array $options |
||
943 | * @param string $fields |
||
944 | * @param bool $showStart |
||
945 | * @param bool $showFields |
||
946 | * @param bool $showEnd |
||
947 | * @return string |
||
948 | */ |
||
949 | 9 | protected function render($options, $fields, $showStart, $showFields, $showEnd) |
|
967 | |||
968 | /** |
||
969 | * @param $formOptions |
||
970 | * @return array |
||
971 | */ |
||
972 | 9 | protected function buildFormOptionsForFormBuilder($formOptions) |
|
988 | |||
989 | |||
990 | /** |
||
991 | * Get template from options if provided, otherwise fallback to config. |
||
992 | * |
||
993 | * @return mixed |
||
994 | */ |
||
995 | 9 | protected function getTemplate() |
|
999 | |||
1000 | /** |
||
1001 | * Get all fields that are not rendered. |
||
1002 | * |
||
1003 | * @return array |
||
1004 | */ |
||
1005 | 2 | protected function getUnrenderedFields() |
|
1018 | |||
1019 | /** |
||
1020 | * Prevent adding fields with same name. |
||
1021 | * |
||
1022 | * @param string $name |
||
1023 | * @throws \InvalidArgumentException |
||
1024 | * @return void |
||
1025 | */ |
||
1026 | 61 | protected function preventDuplicate($name) |
|
1032 | |||
1033 | /** |
||
1034 | * Returns and checks the type of the field. |
||
1035 | * |
||
1036 | * @param string $type |
||
1037 | * @return string |
||
1038 | */ |
||
1039 | 65 | protected function getFieldType($type) |
|
1045 | |||
1046 | /** |
||
1047 | * Check if form is named form. |
||
1048 | * |
||
1049 | * @return void |
||
1050 | */ |
||
1051 | 129 | protected function checkIfNamedForm() |
|
1057 | |||
1058 | /** |
||
1059 | * Set up options on single field depending on form options. |
||
1060 | * |
||
1061 | * @param string $name |
||
1062 | * @param $options |
||
1063 | */ |
||
1064 | 65 | protected function setupFieldOptions($name, &$options) |
|
1068 | |||
1069 | /** |
||
1070 | * Set namespace to model if form is named so the data is bound properly. |
||
1071 | * Returns true if model is changed, otherwise false. |
||
1072 | * |
||
1073 | * @return bool |
||
1074 | */ |
||
1075 | 21 | protected function setupNamedModel() |
|
1096 | |||
1097 | /** |
||
1098 | * Set form builder instance on helper so we can use it later. |
||
1099 | * |
||
1100 | * @param FormBuilder $formBuilder |
||
1101 | * @return $this |
||
1102 | */ |
||
1103 | 129 | public function setFormBuilder(FormBuilder $formBuilder) |
|
1109 | |||
1110 | /** |
||
1111 | * Returns the instance of the FormBuilder. |
||
1112 | * |
||
1113 | * @return FormBuilder |
||
1114 | */ |
||
1115 | 20 | public function getFormBuilder() |
|
1119 | |||
1120 | /** |
||
1121 | * Set the Validator instance on this so we can use it later. |
||
1122 | * |
||
1123 | * @param ValidatorFactory $validator |
||
1124 | * @return $this |
||
1125 | */ |
||
1126 | 129 | public function setValidator(ValidatorFactory $validator) |
|
1132 | |||
1133 | /** |
||
1134 | * Returns the validator instance. |
||
1135 | * |
||
1136 | * @return Validator |
||
1137 | */ |
||
1138 | 1 | public function getValidator() |
|
1142 | |||
1143 | /** |
||
1144 | * Exclude some fields from rendering. |
||
1145 | * |
||
1146 | * @return $this |
||
1147 | */ |
||
1148 | public function exclude(array $fields) |
||
1154 | |||
1155 | /** |
||
1156 | * If form is named form, modify names to be contained in single key (parent[child_field_name]). |
||
1157 | * |
||
1158 | * @param string $name |
||
1159 | * @return string |
||
1160 | */ |
||
1161 | 65 | protected function getFieldName($name) |
|
1178 | |||
1179 | /** |
||
1180 | * Disable all fields in a form. |
||
1181 | */ |
||
1182 | 1 | public function disableFields() |
|
1188 | |||
1189 | /** |
||
1190 | * Enable all fields in a form. |
||
1191 | */ |
||
1192 | 1 | public function enableFields() |
|
1198 | |||
1199 | /** |
||
1200 | * Validate the form. |
||
1201 | * |
||
1202 | * @param array $validationRules |
||
1203 | * @param array $messages |
||
1204 | * @return Validator |
||
1205 | */ |
||
1206 | 9 | public function validate($validationRules = [], $messages = []) |
|
1219 | |||
1220 | /** |
||
1221 | * Get validation rules for the form. |
||
1222 | * |
||
1223 | * @param array $overrideRules |
||
1224 | * @return array |
||
1225 | */ |
||
1226 | 1 | public function getRules($overrideRules = []) |
|
1232 | |||
1233 | /** |
||
1234 | * Redirects to a destination when form is invalid. |
||
1235 | * |
||
1236 | * @param string|null $destination The target url. |
||
1237 | * @return HttpResponseException |
||
1238 | */ |
||
1239 | 3 | public function redirectIfNotValid($destination = null) |
|
1253 | |||
1254 | /** |
||
1255 | * Get all form field attributes, including child forms, in a flat array. |
||
1256 | * |
||
1257 | * @return array |
||
1258 | */ |
||
1259 | 3 | public function getAllAttributes() |
|
1263 | |||
1264 | /** |
||
1265 | * Check if the form is valid. |
||
1266 | * |
||
1267 | * @return bool |
||
1268 | */ |
||
1269 | 9 | public function isValid() |
|
1283 | |||
1284 | /** |
||
1285 | * Optionally change the validation result, and/or add error messages. |
||
1286 | * |
||
1287 | * @param Form $mainForm |
||
1288 | * @param bool $isValid |
||
1289 | * @return void|array |
||
1290 | */ |
||
1291 | 9 | public function alterValid(Form $mainForm, &$isValid) |
|
1295 | |||
1296 | /** |
||
1297 | * Get validation errors. |
||
1298 | * |
||
1299 | * @return array |
||
1300 | */ |
||
1301 | 8 | public function getErrors() |
|
1314 | |||
1315 | /** |
||
1316 | * Get all Request values from all fields, and nothing else. |
||
1317 | * |
||
1318 | * @param bool $with_nulls |
||
1319 | * @return array |
||
1320 | */ |
||
1321 | 3 | public function getFieldValues($with_nulls = true) |
|
1344 | |||
1345 | /** |
||
1346 | * Optionally mess with this form's $values before it's returned from getFieldValues(). |
||
1347 | * |
||
1348 | * @param array $values |
||
1349 | * @return void |
||
1350 | */ |
||
1351 | 3 | public function alterFieldValues(array &$values) |
|
1354 | |||
1355 | /** |
||
1356 | * Throw an exception indicating a field does not exist on the class. |
||
1357 | * |
||
1358 | * @param string $name |
||
1359 | * @throws \InvalidArgumentException |
||
1360 | * @return void |
||
1361 | */ |
||
1362 | 2 | protected function fieldDoesNotExist($name) |
|
1366 | |||
1367 | /** |
||
1368 | * Method filterFields used as *Main* method for starting |
||
1369 | * filtering and request field mutating process. |
||
1370 | * |
||
1371 | * @return \Kris\LaravelFormBuilder\Form |
||
1372 | */ |
||
1373 | 129 | public function filterFields() |
|
1409 | |||
1410 | /** |
||
1411 | * Method getFilters used to return array of all binded filters to form fields. |
||
1412 | * |
||
1413 | * @return array |
||
1414 | */ |
||
1415 | 129 | public function getFilters() |
|
1424 | |||
1425 | /** |
||
1426 | * If lockFiltering is set to true then we will not |
||
1427 | * filter fields and mutate request data binded to fields. |
||
1428 | * |
||
1429 | * @return \Kris\LaravelFormBuilder\Form |
||
1430 | */ |
||
1431 | 1 | public function lockFiltering() |
|
1436 | |||
1437 | /** |
||
1438 | * Unlock fields filtering/mutating. |
||
1439 | * |
||
1440 | * @return \Kris\LaravelFormBuilder\Form |
||
1441 | */ |
||
1442 | public function unlockFiltering() |
||
1447 | |||
1448 | /** |
||
1449 | * Method isFilteringLocked used to check |
||
1450 | * if current filteringLocked property status is set to true. |
||
1451 | * |
||
1452 | * @return bool |
||
1453 | */ |
||
1454 | 129 | public function isFilteringLocked() |
|
1458 | |||
1459 | /** |
||
1460 | * Method getRawValues returns Unfiltered/Unmutated fields -> values. |
||
1461 | * |
||
1462 | * @return array |
||
1463 | */ |
||
1464 | public function getRawValues() |
||
1473 | } |
||
1474 |
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: