Completed
Pull Request — master (#376)
by
unknown
03:53
created

FormField::prepareOptions()   D

Complexity

Conditions 13
Paths 336

Size

Total Lines 62
Code Lines 35

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 35
CRAP Score 13

Importance

Changes 0
Metric Value
cc 13
eloc 35
nc 336
nop 1
dl 0
loc 62
ccs 35
cts 35
cp 1
crap 13
rs 4.5568
c 0
b 0
f 0

How to fix   Long Method    Complexity   

Long Method

Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.

For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.

Commonly applied refactorings include:

1
<?php
2
3
namespace Kris\LaravelFormBuilder\Fields;
4
5
use Kris\LaravelFormBuilder\Filters\Exception\FilterAlreadyBindedException;
6
use Kris\LaravelFormBuilder\Filters\FilterInterface;
7
use Kris\LaravelFormBuilder\Filters\FilterResolver;
8
use Kris\LaravelFormBuilder\Form;
9
use Kris\LaravelFormBuilder\FormHelper;
10
11
/**
12
 * Class FormField
13
 *
14
 * @package Kris\LaravelFormBuilder\Fields
15
 */
16
abstract class FormField
17
{
18
    /**
19
     * Name of the field.
20
     *
21
     * @var string
22
     */
23
    protected $name;
24
25
    /**
26
     * Type of the field.
27
     *
28
     * @var string
29
     */
30
    protected $type;
31
32
    /**
33
     * All options for the field.
34
     *
35
     * @var array
36
     */
37
    protected $options = [];
38
39
    /**
40
     * Is field rendered.
41
     *
42
     * @var bool
43
     */
44
    protected $rendered = false;
45
46
    /**
47
     * @var Form
48
     */
49
    protected $parent;
50
51
    /**
52
     * @var string
53
     */
54
    protected $template;
55
56
    /**
57
     * @var FormHelper
58
     */
59
    protected $formHelper;
60
61
    /**
62
     * Name of the property for value setting.
63
     *
64
     * @var string
65
     */
66
    protected $valueProperty = 'value';
67
68
    /**
69
     * Name of the property for default value.
70
     *
71
     * @var string
72
     */
73
    protected $defaultValueProperty = 'default_value';
74
75
    /**
76
     * Is default value set?
77
     *
78
     * @var bool|false
79
     */
80
    protected $hasDefault = false;
81
82
    /**
83
     * @var \Closure|null
84
     */
85
    protected $valueClosure = null;
86
87
    /**
88
     * Array of filters key(alias/name) => objects.
89
     *
90
     * @var array
91
     */
92
    protected $filters = [];
93
94
    /**
95
     * Override filters with same alias/name for field.
96
     *
97
     * @var bool
98
     */
99
    protected $filtersOverride = false;
100
101
    /**
102
     * @param string $name
103
     * @param string $type
104
     * @param Form $parent
105
     * @param array $options
106
     */
107 96
    public function __construct($name, $type, Form $parent, array $options = [])
108
    {
109 96
        $this->name = $name;
110 96
        $this->type = $type;
111 96
        $this->parent = $parent;
112 96
        $this->formHelper = $this->parent->getFormHelper();
113 96
        $this->setTemplate();
114 96
        $this->setDefaultOptions($options);
115 96
        $this->setupValue();
116 91
        $this->initFilters();
117 85
    }
118
119
120
    /**
121
     * Setup the value of the form field.
122
     *
123
     * @return void
124
     */
125 96
    protected function setupValue()
126
    {
127 96
        $value = $this->getOption($this->valueProperty);
128 96
        $isChild = $this->getOption('is_child');
129
130 96
        if ($value instanceof \Closure) {
131
            $this->valueClosure = $value;
132
        }
133
134 96
        if (($value === null || $value instanceof \Closure) && !$isChild) {
135 86
            $this->setValue($this->getModelValueAttribute($this->parent->getModel(), $this->name));
136 21
        } elseif (!$isChild) {
137 13
            $this->hasDefault = true;
138
        }
139 91
    }
140
141
    /**
142
     * Get the template, can be config variable or view path.
143
     *
144
     * @return string
145
     */
146
    abstract protected function getTemplate();
147
148
    /**
149
     * @return string
150
     */
151 33
    protected function getViewTemplate()
152
    {
153 33
        return $this->parent->getTemplatePrefix() . $this->getOption('template', $this->template);
154
    }
155
156
    /**
157
     * Render the field.
158
     *
159
     * @param array $options
160
     * @param bool  $showLabel
161
     * @param bool  $showField
162
     * @param bool  $showError
163
     * @return string
164
     */
165 33
    public function render(array $options = [], $showLabel = true, $showField = true, $showError = true)
166
    {
167 33
        $this->prepareOptions($options);
168 33
        $value = $this->getValue();
169 33
        $defaultValue = $this->getDefaultValue();
170
171 33
        if ($showField) {
172 33
            $this->rendered = true;
173
        }
174
175
        // Override default value with value
176 33
        if (!$this->isValidValue($value) && $this->isValidValue($defaultValue)) {
177
            $this->setOption($this->valueProperty, $defaultValue);
178
        }
179
180 33
        if (!$this->needsLabel()) {
181 9
            $showLabel = false;
182
        }
183
184 33
        if ($showError) {
185 32
            $showError = $this->parent->haveErrorsEnabled();
186
        }
187
188 33
        $data = $this->getRenderData();
189
190 33
        return $this->formHelper->getView()->make(
191 33
            $this->getViewTemplate(),
192
            $data + [
193 33
                'name' => $this->name,
194 33
                'nameKey' => $this->getNameKey(),
195 33
                'type' => $this->type,
196 33
                'options' => $this->options,
197 33
                'showLabel' => $showLabel,
198 33
                'showField' => $showField,
199 33
                'showError' => $showError
200
            ]
201 33
        )->render();
202
    }
203
204
    /**
205
     * Return the extra render data for this form field, passed into the field's template directly.
206
     *
207
     * @return array
208
     */
209 33
    protected function getRenderData() {
210 33
        return [];
211
    }
212
213
    /**
214
     * Get the attribute value from the model by name.
215
     *
216
     * @param mixed $model
217
     * @param string $name
218
     * @return mixed
219
     */
220 88
    protected function getModelValueAttribute($model, $name)
221
    {
222 88
        $transformedName = $this->transformKey($name);
223 88
        if (is_string($model)) {
224
            return $model;
225 88
        } elseif (is_object($model)) {
226 3
            return object_get($model, $transformedName);
227 88
        } elseif (is_array($model)) {
228 87
            return array_get($model, $transformedName);
229
        }
230 5
    }
231
232
    /**
233
     * Transform array like syntax to dot syntax.
234
     *
235
     * @param string $key
236
     * @return mixed
237
     */
238 96
    protected function transformKey($key)
239
    {
240 96
        return $this->formHelper->transformToDotSyntax($key);
241
    }
242
243
    /**
244
     * Prepare options for rendering.
245
     *
246
     * @param array $options
247
     * @return array
248
     */
249 96
    protected function prepareOptions(array $options = [])
250
    {
251 96
        $helper = $this->formHelper;
252 96
        $rulesParser = $helper->createRulesParser($this);
253 96
        $rules = $this->getOption('rules');
254 96
        $parsedRules = $rules ? $rulesParser->parse($rules) : [];
255
256 96
        $this->options = $helper->mergeOptions($this->options, $options);
257
258 96
        foreach (['attr', 'label_attr', 'wrapper'] as $appendable) {
259
            // Append values to the 'class' attribute
260 96
            if ($this->getOption("{$appendable}.class_append")) {
261
                // Combine the current class attribute with the appends
262 3
                $append = $this->getOption("{$appendable}.class_append");
263 3
                $classAttribute = $this->getOption("{$appendable}.class", '').' '.$append;
264 3
                $this->setOption("{$appendable}.class", $classAttribute);
265
266
                // Then remove the class_append option to prevent it from showing up as an attribute in the HTML
267 96
                $this->setOption("{$appendable}.class_append", null);
268
            }
269
        }
270
271 96
        if ($this->getOption('attr.multiple') && !$this->getOption('tmp.multipleBracesSet')) {
272 2
            $this->name = $this->name.'[]';
273 2
            $this->setOption('tmp.multipleBracesSet', true);
274
        }
275
276 96
        if ($this->parent->haveErrorsEnabled()) {
277 96
            $this->addErrorClass();
278
        }
279
280 96
        if ($this->getOption('required') === true || isset($parsedRules['required'])) {
281 4
            $lblClass = $this->getOption('label_attr.class', '');
282 4
            $requiredClass = $helper->getConfig('defaults.required_class', 'required');
283
284 4
            if (! str_contains($lblClass, $requiredClass)) {
285 4
                $lblClass .= ' '.$requiredClass;
286 4
                $this->setOption('label_attr.class', $lblClass);
287
            }
288
289 4
            if ($this->parent->clientValidationEnabled()) {
290 3
                $this->setOption('attr.required', 'required');
291
292 3
                if ($parsedRules) {
0 ignored issues
show
Bug Best Practice introduced by
The expression $parsedRules of type array is implicitly converted to a boolean; are you sure this is intended? If so, consider using ! empty($expr) instead to make it clear that you intend to check for an array without elements.

This check marks implicit conversions of arrays to boolean values in a comparison. While in PHP an empty array is considered to be equal (but not identical) to false, this is not always apparent.

Consider making the comparison explicit by using empty(..) or ! empty(...) instead.

Loading history...
293 1
                    $attrs = $this->getOption('attr') + $parsedRules;
294 1
                    $this->setOption('attr', $attrs);
295
                }
296
            }
297
        }
298
299 96
        $this->setOption('wrapperAttrs', $helper->prepareAttributes($this->getOption('wrapper')));
300 96
        $this->setOption('errorAttrs', $helper->prepareAttributes($this->getOption('errors')));
301
302 96
        if ($this->getOption('help_block.text')) {
303 1
            $this->setOption(
304 1
                'help_block.helpBlockAttrs',
305 1
                $helper->prepareAttributes($this->getOption('help_block.attr'))
306
            );
307
        }
308
309 96
        return $this->options;
310
    }
311
312
    /**
313
     * Get name of the field.
314
     *
315
     * @return string
316
     */
317 37
    public function getName()
318
    {
319 37
        return $this->name;
320
    }
321
322
    /**
323
     * Set name of the field.
324
     *
325
     * @param string $name
326
     * @return $this
327
     */
328 12
    public function setName($name)
329
    {
330 12
        $this->name = $name;
331
332 12
        return $this;
333
    }
334
335
    /**
336
     * Get dot notation key for fields.
337
     *
338
     * @return string
339
     **/
340 52
    public function getNameKey()
341
    {
342 52
        return $this->transformKey($this->name);
343
    }
344
345
    /**
346
     * Get field options.
347
     *
348
     * @return array
349
     */
350 12
    public function getOptions()
351
    {
352 12
        return $this->options;
353
    }
354
355
    /**
356
     * Get single option from options array. Can be used with dot notation ('attr.class').
357
     *
358
     * @param string $option
359
     * @param mixed|null $default
360
     * @return mixed
361
     */
362 96
    public function getOption($option, $default = null)
363
    {
364 96
        return array_get($this->options, $option, $default);
365
    }
366
367
    /**
368
     * Set field options.
369
     *
370
     * @param array $options
371
     * @return $this
372
     */
373 12
    public function setOptions($options)
374
    {
375 12
        $this->options = $this->prepareOptions($options);
376
377 12
        return $this;
378
    }
379
380
    /**
381
     * Set single option on the field.
382
     *
383
     * @param string $name
384
     * @param mixed $value
385
     * @return $this
386
     */
387 96
    public function setOption($name, $value)
388
    {
389 96
        array_set($this->options, $name, $value);
390
391 96
        return $this;
392
    }
393
394
    /**
395
     * Get the type of the field.
396
     *
397
     * @return string
398
     */
399 56
    public function getType()
400
    {
401 56
        return $this->type;
402
    }
403
404
    /**
405
     * Set type of the field.
406
     *
407
     * @param mixed $type
408
     * @return $this
409
     */
410 1
    public function setType($type)
411
    {
412 1
        if ($this->formHelper->getFieldType($type)) {
413 1
            $this->type = $type;
414
        }
415
416 1
        return $this;
417
    }
418
419
    /**
420
     * @return Form
421
     */
422 96
    public function getParent()
423
    {
424 96
        return $this->parent;
425
    }
426
427
    /**
428
     * Check if the field is rendered.
429
     *
430
     * @return bool
431
     */
432 4
    public function isRendered()
433
    {
434 4
        return $this->rendered;
435
    }
436
437
    /**
438
     * Default options for field.
439
     *
440
     * @return array
441
     */
442 75
    protected function getDefaults()
443
    {
444 75
        return [];
445
    }
446
447
    /**
448
     * Defaults used across all fields.
449
     *
450
     * @return array
451
     */
452 96
    private function allDefaults()
453
    {
454
        return [
455 96
            'wrapper' => ['class' => $this->formHelper->getConfig('defaults.wrapper_class')],
456 96
            'attr' => ['class' => $this->formHelper->getConfig('defaults.field_class')],
457 96
            'help_block' => ['text' => null, 'tag' => 'p', 'attr' => [
458 96
                'class' => $this->formHelper->getConfig('defaults.help_block_class')
459
            ]],
460
            'value' => null,
461
            'default_value' => null,
462
            'label' => null,
463
            'label_show' => true,
464
            'is_child' => false,
465 96
            'label_attr' => ['class' => $this->formHelper->getConfig('defaults.label_class')],
466 96
            'errors' => ['class' => $this->formHelper->getConfig('defaults.error_class')],
467
            'rules' => [],
468
            'error_messages' => []
469
        ];
470
    }
471
472
    /**
473
     * Get real name of the field without form namespace.
474
     *
475
     * @return string
476
     */
477 95
    public function getRealName()
478
    {
479 95
        return $this->getOption('real_name', $this->name);
480
    }
481
482
    /**
483
     * @param $value
484
     * @return $this
485
     */
486 90
    public function setValue($value)
487
    {
488 90
        if ($this->hasDefault) {
489 1
            return $this;
490
        }
491
492 90
        $closure = $this->valueClosure;
493
494 90
        if ($closure instanceof \Closure) {
495
            $value = $closure($value ?: null);
496
        }
497
498 90
        if (!$this->isValidValue($value)) {
499 87
            $value = $this->getOption($this->defaultValueProperty);
500
        }
501
502 90
        $this->options[$this->valueProperty] = $value;
503
504 90
        return $this;
505
    }
506
507
    /**
508
     * Set the template property on the object.
509
     *
510
     * @return void
511
     */
512 96
    private function setTemplate()
513
    {
514 96
        $this->template = $this->formHelper->getConfig($this->getTemplate(), $this->getTemplate());
515 96
    }
516
517
    /**
518
     * Add error class to wrapper if validation errors exist.
519
     *
520
     * @return void
521
     */
522 96
    protected function addErrorClass()
523
    {
524 96
        $errors = $this->parent->getRequest()->session()->get('errors');
525
526 96
        if ($errors && $errors->has($this->getNameKey())) {
527
            $errorClass = $this->formHelper->getConfig('defaults.wrapper_error_class');
528
            $wrapperClass = $this->getOption('wrapper.class');
529
530
            if ($this->getOption('wrapper') && !str_contains($wrapperClass, $errorClass)) {
531
                $wrapperClass .= ' ' . $errorClass;
532
                $this->setOption('wrapper.class', $wrapperClass);
533
            }
534
        }
535 96
    }
536
537
    /**
538
     * Merge all defaults with field specific defaults and set template if passed.
539
     *
540
     * @param array $options
541
     */
542 96
    protected function setDefaultOptions(array $options = [])
543
    {
544 96
        $this->options = $this->formHelper->mergeOptions($this->allDefaults(), $this->getDefaults());
545 96
        $this->options = $this->prepareOptions($options);
546
547 96
        $defaults = $this->setDefaultClasses($options);
548 96
        $this->options = $this->formHelper->mergeOptions($this->options, $defaults);
549
550 96
        $this->setupLabel();
551 96
    }
552
553
    /**
554
     * Creates default wrapper classes for the form element.
555
     *
556
     * @param array $options
557
     * @return array
558
     */
559 96
    protected function setDefaultClasses(array $options = [])
560
    {
561 96
        $wrapper_class = $this->formHelper->getConfig('defaults.' . $this->type . '.wrapper_class', '');
562 96
        $label_class = $this->formHelper->getConfig('defaults.' . $this->type . '.label_class', '');
563 96
        $field_class = $this->formHelper->getConfig('defaults.' . $this->type . '.field_class', '');
564
565 96
        $defaults = [];
566 96
        if ($wrapper_class && !array_get($options, 'wrapper.class')) {
567
            $defaults['wrapper']['class'] = $wrapper_class;
568
        }
569 96
        if ($label_class && !array_get($options, 'label_attr.class')) {
570
            $defaults['label_attr']['class'] = $label_class;
571
        }
572 96
        if ($field_class && !array_get($options, 'attr.class')) {
573 1
            $defaults['attr']['class'] = $field_class;
574
        }
575 96
        return $defaults;
576
    }
577
578
    /**
579
     * Setup the label for the form field.
580
     *
581
     * @return void
582
     */
583 96
    protected function setupLabel()
584
    {
585 96
        if ($this->getOption('label') !== null) {
586 22
            return;
587
        }
588
589 94
        if ($langName = $this->parent->getLanguageName()) {
590 4
            $label = sprintf('%s.%s', $langName, $this->getRealName());
591
        } else {
592 91
            $label = $this->getRealName();
593
        }
594
595 94
        $this->setOption('label', $this->formHelper->formatLabel($label));
596 94
    }
597
598
    /**
599
     * Check if fields needs label.
600
     *
601
     * @return bool
602
     */
603 33
    protected function needsLabel()
604
    {
605
        // If field is <select> and child of choice, we don't need label for it
606 33
        $isChildSelect = $this->type == 'select' && $this->getOption('is_child') === true;
607
608 33
        if ($this->type == 'hidden' || $isChildSelect) {
609 9
            return false;
610
        }
611
612 29
        return true;
613
    }
614
615
    /**
616
     * Disable field.
617
     *
618
     * @return $this
619
     */
620 1
    public function disable()
621
    {
622 1
        $this->setOption('attr.disabled', 'disabled');
623
624 1
        return $this;
625
    }
626
627
    /**
628
     * Enable field.
629
     *
630
     * @return $this
631
     */
632 1
    public function enable()
633
    {
634 1
        array_forget($this->options, 'attr.disabled');
635
636 1
        return $this;
637
    }
638
639
    /**
640
     * Get validation rules for a field if any with label for attributes.
641
     *
642
     * @return array|null
643
     */
644 9
    public function getValidationRules()
645
    {
646 9
        $rules = $this->getOption('rules', []);
647 9
        $name = $this->getNameKey();
648 9
        $messages = $this->getOption('error_messages', []);
649 9
        $formName = $this->formHelper->transformToDotSyntax($this->parent->getName());
650
651 9
        if ($messages && $formName) {
652 1
            $newMessages = [];
653 1
            foreach ($messages as $messageKey => $message) {
654 1
                $messageKey = sprintf('%s.%s', $formName, $messageKey);
655 1
                $newMessages[$messageKey] = $message;
656
            }
657 1
            $messages = $newMessages;
658
        }
659
660 9
        if (!$rules) {
661 2
            return [];
662
        }
663
664
        return [
665 8
            'rules' => [$name => $rules],
666 8
            'attributes' => [$name => $this->getOption('label')],
667 8
            'error_messages' => $messages
668
        ];
669
    }
670
671
    /**
672
     * Get this field's attributes, probably just one.
673
     *
674
     * @return array
675
     */
676 3
    public function getAllAttributes()
677
    {
678 3
        return [$this->getNameKey()];
679
    }
680
681
    /**
682
     * Get value property.
683
     *
684
     * @param mixed|null $default
685
     * @return mixed
686
     */
687 36
    public function getValue($default = null)
688
    {
689 36
        return $this->getOption($this->valueProperty, $default);
690
    }
691
692
    /**
693
     * Get default value property.
694
     *
695
     * @param mixed|null $default
696
     * @return mixed
697
     */
698 33
    public function getDefaultValue($default = null)
699
    {
700 33
        return $this->getOption($this->defaultValueProperty, $default);
701
    }
702
703
    /**
704
     * Check if provided value is valid for this type.
705
     *
706
     * @return bool
707
     */
708 91
    protected function isValidValue($value)
709
    {
710 91
        return $value !== null;
711
    }
712
713
    /**
714
     * Method initFilters used to initialize filters
715
     * from field options and bind it to the same.
716
     *
717
     * @return $this
718
     */
719 91
    protected function initFilters()
720
    {
721
        // If override status is set in field options to true
722
        // we will change filtersOverride property value to true
723
        // so we can override existing filters with registered
724
        // alias/name in addFilter method.
725 91
        $overrideStatus = $this->getOption('filters_override', false);
726 91
        if ($overrideStatus) {
727 2
            $this->setFiltersOverride(true);
728
        }
729
730
        // Get filters and bind it to field.
731 91
        $filters = $this->getOption('filters', []);
732 91
        foreach ($filters as $filter) {
733 8
            $this->addFilter($filter);
734
        }
735
736 85
        return $this;
737
    }
738
739
    /**
740
     * Method setFilters used to set filters to current filters property.
741
     *
742
     * @param  array $filters
743
     *
744
     * @return \Kris\LaravelFormBuilder\Fields\FormField
745
     */
746
    public function setFilters(array $filters)
747
    {
748
        $this->clearFilters();
749
        foreach ($filters as $filter) {
750
            $this->addFilter($filter);
751
        }
752
753
        return $this;
754
    }
755
756
    /**
757
     * Method getFilters returns array of binded filters
758
     * if there are any binded. Otherwise empty array.
759
     *
760
     * @return array
761
     */
762 23
    public function getFilters()
763
    {
764 23
        return $this->filters;
765
    }
766
767
    /**
768
     * @param  string|FilterInterface $filter
769
     *
770
     * @return \Kris\LaravelFormBuilder\Fields\FormField
771
     *
772
     * @throws FilterAlreadyBindedException
773
     */
774 8
    public function addFilter($filter)
775
    {
776
        // Resolve filter object from string/object or throw Ex.
777 8
        $filterObj = FilterResolver::instance($filter);
778
779
        // If filtersOverride is allowed we will override filter
780
        // with same alias/name if there is one with new resolved filter.
781 8
        if ($this->getFiltersOverride()) {
782 1
            if ($key = array_search($filterObj->getName(), $this->getFilters())) {
783
                $this->filters[$key] = $filterObj;
784
            } else {
785 1
                $this->filters[$filterObj->getName()] = $filterObj;
786
            }
787
        } else {
788
            // If filtersOverride is disabled and we found
789
            // equal alias defined we will throw Ex.
790 7
            if (array_key_exists($filterObj->getName(), $this->getFilters())) {
791 1
                $ex = new FilterAlreadyBindedException($filterObj->getName(), $this->getName());
792 1
                throw $ex;
793
            }
794
795
            // Filter with resolvedFilter alias/name doesn't exist
796
            // so we will bind it as new one to field.
797 7
            $this->filters[$filterObj->getName()] = $filterObj;
798
        }
799
800 8
        return $this;
801
    }
802
803
    /**
804
     * Method removeFilter used to remove filter by provided alias/name.
805
     *
806
     * @param  string $name
807
     *
808
     * @return \Kris\LaravelFormBuilder\Fields\FormField
809
     */
810
    public function removeFilter($name)
811
    {
812
        $filters = $this->getFilters();
813
        if (array_key_exists($name, $filters)) {
814
            unset($filters[$name]);
815
            $this->filters = $filters;
816
        }
817
818
        return $this;
819
    }
820
821
    /**
822
     * Method removeFilters used to remove filters by provided aliases/names.
823
     *
824
     * @param  array $filterNames
825
     *
826
     * @return \Kris\LaravelFormBuilder\Fields\FormField
827
     */
828
    public function removeFilters(array $filterNames)
829
    {
830
        $filters = $this->getFilters();
831
        foreach ($filterNames as $filterName) {
832
            if (array_key_exists($filterName, $filters)) {
833
                unset($filters[$filterName]);
834
                $this->filters = $filters;
835
            }
836
        }
837
838
        return $this;
839
    }
840
841
    /**
842
     * Method clearFilters used to empty current filters property.
843
     *
844
     * @return \Kris\LaravelFormBuilder\Fields\FormField
845
     */
846
    public function clearFilters()
847
    {
848
        $this->filters = [];
849
        return $this;
850
    }
851
852
    /**
853
     * Method used to set FiltersOverride status to provided value.
854
     *
855
     * @param $status
856
     *
857
     * @return \Kris\LaravelFormBuilder\Fields\FormField
858
     */
859 2
    public function setFiltersOverride($status)
860
    {
861 2
        $this->filtersOverride = $status;
862 2
        return $this;
863
    }
864
865
    /**
866
     * @return bool
867
     */
868 9
    public function getFiltersOverride()
869
    {
870 9
        return $this->filtersOverride;
871
    }
872
}
873