Completed
Push — master ( 2f14ed...824b2e )
by Kristijan
12s
created

FormField::getName()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 0
dl 0
loc 4
rs 10
c 0
b 0
f 0
ccs 2
cts 2
cp 1
crap 1
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
     * Raw/unfiltered field value.
96
     *
97
     * @var mixed $rawValues
98
     */
99
    protected $rawValue;
100
101
    /**
102
     * Override filters with same alias/name for field.
103
     *
104
     * @var bool
105
     */
106
    protected $filtersOverride = false;
107
108
    /**
109
     * @param string $name
110
     * @param string $type
111
     * @param Form $parent
112
     * @param array $options
113
     */
114 96
    public function __construct($name, $type, Form $parent, array $options = [])
115
    {
116 96
        $this->name = $name;
117 96
        $this->type = $type;
118 96
        $this->parent = $parent;
119 96
        $this->formHelper = $this->parent->getFormHelper();
120 96
        $this->setTemplate();
121 96
        $this->setDefaultOptions($options);
122 96
        $this->setupValue();
123 91
        $this->initFilters();
124 91
    }
125
126
127
    /**
128
     * Setup the value of the form field.
129
     *
130
     * @return void
131
     */
132 96
    protected function setupValue()
133
    {
134 96
        $value = $this->getOption($this->valueProperty);
135 96
        $isChild = $this->getOption('is_child');
136
137 96
        if ($value instanceof \Closure) {
138
            $this->valueClosure = $value;
139
        }
140
141 96
        if (($value === null || $value instanceof \Closure) && !$isChild) {
142 86
            $this->setValue($this->getModelValueAttribute($this->parent->getModel(), $this->name));
143 21
        } elseif (!$isChild) {
144 13
            $this->hasDefault = true;
145
        }
146 91
    }
147
148
    /**
149
     * Get the template, can be config variable or view path.
150
     *
151
     * @return string
152
     */
153
    abstract protected function getTemplate();
154
155
    /**
156
     * @return string
157
     */
158 33
    protected function getViewTemplate()
159
    {
160 33
        return $this->parent->getTemplatePrefix() . $this->getOption('template', $this->template);
161
    }
162
163
    /**
164
     * Render the field.
165
     *
166
     * @param array $options
167
     * @param bool  $showLabel
168
     * @param bool  $showField
169
     * @param bool  $showError
170
     * @return string
171
     */
172 33
    public function render(array $options = [], $showLabel = true, $showField = true, $showError = true)
173
    {
174 33
        $this->prepareOptions($options);
175 33
        $value = $this->getValue();
176 33
        $defaultValue = $this->getDefaultValue();
177
178 33
        if ($showField) {
179 33
            $this->rendered = true;
180
        }
181
182
        // Override default value with value
183 33
        if (!$this->isValidValue($value) && $this->isValidValue($defaultValue)) {
184
            $this->setOption($this->valueProperty, $defaultValue);
185
        }
186
187 33
        if (!$this->needsLabel()) {
188 9
            $showLabel = false;
189
        }
190
191 33
        if ($showError) {
192 32
            $showError = $this->parent->haveErrorsEnabled();
193
        }
194
195 33
        $data = $this->getRenderData();
196
197 33
        return $this->formHelper->getView()->make(
198 33
            $this->getViewTemplate(),
199
            $data + [
200 33
                'name' => $this->name,
201 33
                'nameKey' => $this->getNameKey(),
202 33
                'type' => $this->type,
203 33
                'options' => $this->options,
204 33
                'showLabel' => $showLabel,
205 33
                'showField' => $showField,
206 33
                'showError' => $showError
207
            ]
208 33
        )->render();
209
    }
210
211
    /**
212
     * Return the extra render data for this form field, passed into the field's template directly.
213
     *
214
     * @return array
215
     */
216 33
    protected function getRenderData() {
217 33
        return [];
218
    }
219
220
    /**
221
     * Get the attribute value from the model by name.
222
     *
223
     * @param mixed $model
224
     * @param string $name
225
     * @return mixed
226
     */
227 88
    protected function getModelValueAttribute($model, $name)
228
    {
229 88
        $transformedName = $this->transformKey($name);
230 88
        if (is_string($model)) {
231
            return $model;
232 88
        } elseif (is_object($model)) {
233 3
            return object_get($model, $transformedName);
234 88
        } elseif (is_array($model)) {
235 87
            return array_get($model, $transformedName);
236
        }
237 5
    }
238
239
    /**
240
     * Transform array like syntax to dot syntax.
241
     *
242
     * @param string $key
243
     * @return mixed
244
     */
245 96
    protected function transformKey($key)
246
    {
247 96
        return $this->formHelper->transformToDotSyntax($key);
248
    }
249
250
    /**
251
     * Prepare options for rendering.
252
     *
253
     * @param array $options
254
     * @return array
255
     */
256 96
    protected function prepareOptions(array $options = [])
257
    {
258 96
        $helper = $this->formHelper;
259 96
        $rulesParser = $helper->createRulesParser($this);
260 96
        $rules = $this->getOption('rules');
261 96
        $parsedRules = $rules ? $rulesParser->parse($rules) : [];
262
263 96
        $this->options = $helper->mergeOptions($this->options, $options);
264
265 96
        foreach (['attr', 'label_attr', 'wrapper'] as $appendable) {
266
            // Append values to the 'class' attribute
267 96
            if ($this->getOption("{$appendable}.class_append")) {
268
                // Combine the current class attribute with the appends
269 3
                $append = $this->getOption("{$appendable}.class_append");
270 3
                $classAttribute = $this->getOption("{$appendable}.class", '').' '.$append;
271 3
                $this->setOption("{$appendable}.class", $classAttribute);
272
273
                // Then remove the class_append option to prevent it from showing up as an attribute in the HTML
274 96
                $this->setOption("{$appendable}.class_append", null);
275
            }
276
        }
277
278 96
        if ($this->getOption('attr.multiple') && !$this->getOption('tmp.multipleBracesSet')) {
279 2
            $this->name = $this->name.'[]';
280 2
            $this->setOption('tmp.multipleBracesSet', true);
281
        }
282
283 96
        if ($this->parent->haveErrorsEnabled()) {
284 96
            $this->addErrorClass();
285
        }
286
287 96
        if ($this->getOption('required') === true || isset($parsedRules['required'])) {
288 4
            $lblClass = $this->getOption('label_attr.class', '');
289 4
            $requiredClass = $helper->getConfig('defaults.required_class', 'required');
290
291 4
            if (! str_contains($lblClass, $requiredClass)) {
292 4
                $lblClass .= ' '.$requiredClass;
293 4
                $this->setOption('label_attr.class', $lblClass);
294
            }
295
296 4
            if ($this->parent->clientValidationEnabled()) {
297 3
                $this->setOption('attr.required', 'required');
298
299 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...
300 1
                    $attrs = $this->getOption('attr') + $parsedRules;
301 1
                    $this->setOption('attr', $attrs);
302
                }
303
            }
304
        }
305
306 96
        $this->setOption('wrapperAttrs', $helper->prepareAttributes($this->getOption('wrapper')));
307 96
        $this->setOption('errorAttrs', $helper->prepareAttributes($this->getOption('errors')));
308
309 96
        if ($this->getOption('help_block.text')) {
310 1
            $this->setOption(
311 1
                'help_block.helpBlockAttrs',
312 1
                $helper->prepareAttributes($this->getOption('help_block.attr'))
313
            );
314
        }
315
316 96
        return $this->options;
317
    }
318
319
    /**
320
     * Get name of the field.
321
     *
322
     * @return string
323
     */
324 39
    public function getName()
325
    {
326 39
        return $this->name;
327
    }
328
329
    /**
330
     * Set name of the field.
331
     *
332
     * @param string $name
333
     * @return $this
334
     */
335 12
    public function setName($name)
336
    {
337 12
        $this->name = $name;
338
339 12
        return $this;
340
    }
341
342
    /**
343
     * Get dot notation key for fields.
344
     *
345
     * @return string
346
     **/
347 52
    public function getNameKey()
348
    {
349 52
        return $this->transformKey($this->name);
350
    }
351
352
    /**
353
     * Get field options.
354
     *
355
     * @return array
356
     */
357 12
    public function getOptions()
358
    {
359 12
        return $this->options;
360
    }
361
362
    /**
363
     * Get single option from options array. Can be used with dot notation ('attr.class').
364
     *
365
     * @param string $option
366
     * @param mixed|null $default
367
     * @return mixed
368
     */
369 96
    public function getOption($option, $default = null)
370
    {
371 96
        return array_get($this->options, $option, $default);
372
    }
373
374
    /**
375
     * Set field options.
376
     *
377
     * @param array $options
378
     * @return $this
379
     */
380 12
    public function setOptions($options)
381
    {
382 12
        $this->options = $this->prepareOptions($options);
383
384 12
        return $this;
385
    }
386
387
    /**
388
     * Set single option on the field.
389
     *
390
     * @param string $name
391
     * @param mixed $value
392
     * @return $this
393
     */
394 96
    public function setOption($name, $value)
395
    {
396 96
        array_set($this->options, $name, $value);
397
398 96
        return $this;
399
    }
400
401
    /**
402
     * Get the type of the field.
403
     *
404
     * @return string
405
     */
406 62
    public function getType()
407
    {
408 62
        return $this->type;
409
    }
410
411
    /**
412
     * Set type of the field.
413
     *
414
     * @param mixed $type
415
     * @return $this
416
     */
417 1
    public function setType($type)
418
    {
419 1
        if ($this->formHelper->getFieldType($type)) {
420 1
            $this->type = $type;
421
        }
422
423 1
        return $this;
424
    }
425
426
    /**
427
     * @return Form
428
     */
429 96
    public function getParent()
430
    {
431 96
        return $this->parent;
432
    }
433
434
    /**
435
     * Check if the field is rendered.
436
     *
437
     * @return bool
438
     */
439 4
    public function isRendered()
440
    {
441 4
        return $this->rendered;
442
    }
443
444
    /**
445
     * Default options for field.
446
     *
447
     * @return array
448
     */
449 75
    protected function getDefaults()
450
    {
451 75
        return [];
452
    }
453
454
    /**
455
     * Defaults used across all fields.
456
     *
457
     * @return array
458
     */
459 96
    private function allDefaults()
460
    {
461
        return [
462 96
            'wrapper' => ['class' => $this->formHelper->getConfig('defaults.wrapper_class')],
463 96
            'attr' => ['class' => $this->formHelper->getConfig('defaults.field_class')],
464 96
            'help_block' => ['text' => null, 'tag' => 'p', 'attr' => [
465 96
                'class' => $this->formHelper->getConfig('defaults.help_block_class')
466
            ]],
467
            'value' => null,
468
            'default_value' => null,
469
            'label' => null,
470
            'label_show' => true,
471
            'is_child' => false,
472 96
            'label_attr' => ['class' => $this->formHelper->getConfig('defaults.label_class')],
473 96
            'errors' => ['class' => $this->formHelper->getConfig('defaults.error_class')],
474
            'rules' => [],
475
            'error_messages' => []
476
        ];
477
    }
478
479
    /**
480
     * Get real name of the field without form namespace.
481
     *
482
     * @return string
483
     */
484 95
    public function getRealName()
485
    {
486 95
        return $this->getOption('real_name', $this->name);
487
    }
488
489
    /**
490
     * @param $value
491
     * @return $this
492
     */
493 90
    public function setValue($value)
494
    {
495 90
        if ($this->hasDefault) {
496 1
            return $this;
497
        }
498
499 90
        $closure = $this->valueClosure;
500
501 90
        if ($closure instanceof \Closure) {
502
            $value = $closure($value ?: null);
503
        }
504
505 90
        if (!$this->isValidValue($value)) {
506 87
            $value = $this->getOption($this->defaultValueProperty);
507
        }
508
509 90
        $this->options[$this->valueProperty] = $value;
510
511 90
        return $this;
512
    }
513
514
    /**
515
     * Set the template property on the object.
516
     *
517
     * @return void
518
     */
519 96
    private function setTemplate()
520
    {
521 96
        $this->template = $this->formHelper->getConfig($this->getTemplate(), $this->getTemplate());
522 96
    }
523
524
    /**
525
     * Add error class to wrapper if validation errors exist.
526
     *
527
     * @return void
528
     */
529 96
    protected function addErrorClass()
530
    {
531 96
        $errors = $this->parent->getRequest()->session()->get('errors');
532
533 96
        if ($errors && $errors->has($this->getNameKey())) {
534
            $errorClass = $this->formHelper->getConfig('defaults.wrapper_error_class');
535
            $wrapperClass = $this->getOption('wrapper.class');
536
537
            if ($this->getOption('wrapper') && !str_contains($wrapperClass, $errorClass)) {
538
                $wrapperClass .= ' ' . $errorClass;
539
                $this->setOption('wrapper.class', $wrapperClass);
540
            }
541
        }
542 96
    }
543
544
    /**
545
     * Merge all defaults with field specific defaults and set template if passed.
546
     *
547
     * @param array $options
548
     */
549 96
    protected function setDefaultOptions(array $options = [])
550
    {
551 96
        $this->options = $this->formHelper->mergeOptions($this->allDefaults(), $this->getDefaults());
552 96
        $this->options = $this->prepareOptions($options);
553
554 96
        $defaults = $this->setDefaultClasses($options);
555 96
        $this->options = $this->formHelper->mergeOptions($this->options, $defaults);
556
557 96
        $this->setupLabel();
558 96
    }
559
560
    /**
561
     * Creates default wrapper classes for the form element.
562
     *
563
     * @param array $options
564
     * @return array
565
     */
566 96
    protected function setDefaultClasses(array $options = [])
567
    {
568 96
        $wrapper_class = $this->formHelper->getConfig('defaults.' . $this->type . '.wrapper_class', '');
569 96
        $label_class = $this->formHelper->getConfig('defaults.' . $this->type . '.label_class', '');
570 96
        $field_class = $this->formHelper->getConfig('defaults.' . $this->type . '.field_class', '');
571
572 96
        $defaults = [];
573 96
        if ($wrapper_class && !array_get($options, 'wrapper.class')) {
574
            $defaults['wrapper']['class'] = $wrapper_class;
575
        }
576 96
        if ($label_class && !array_get($options, 'label_attr.class')) {
577
            $defaults['label_attr']['class'] = $label_class;
578
        }
579 96
        if ($field_class && !array_get($options, 'attr.class')) {
580 1
            $defaults['attr']['class'] = $field_class;
581
        }
582 96
        return $defaults;
583
    }
584
585
    /**
586
     * Setup the label for the form field.
587
     *
588
     * @return void
589
     */
590 96
    protected function setupLabel()
591
    {
592 96
        if ($this->getOption('label') !== null) {
593 22
            return;
594
        }
595
596 94
        if ($langName = $this->parent->getLanguageName()) {
597 4
            $label = sprintf('%s.%s', $langName, $this->getRealName());
598
        } else {
599 91
            $label = $this->getRealName();
600
        }
601
602 94
        $this->setOption('label', $this->formHelper->formatLabel($label));
603 94
    }
604
605
    /**
606
     * Check if fields needs label.
607
     *
608
     * @return bool
609
     */
610 33
    protected function needsLabel()
611
    {
612
        // If field is <select> and child of choice, we don't need label for it
613 33
        $isChildSelect = $this->type == 'select' && $this->getOption('is_child') === true;
614
615 33
        if ($this->type == 'hidden' || $isChildSelect) {
616 9
            return false;
617
        }
618
619 29
        return true;
620
    }
621
622
    /**
623
     * Disable field.
624
     *
625
     * @return $this
626
     */
627 1
    public function disable()
628
    {
629 1
        $this->setOption('attr.disabled', 'disabled');
630
631 1
        return $this;
632
    }
633
634
    /**
635
     * Enable field.
636
     *
637
     * @return $this
638
     */
639 1
    public function enable()
640
    {
641 1
        array_forget($this->options, 'attr.disabled');
642
643 1
        return $this;
644
    }
645
646
    /**
647
     * Get validation rules for a field if any with label for attributes.
648
     *
649
     * @return array|null
650
     */
651 9
    public function getValidationRules()
652
    {
653 9
        $rules = $this->getOption('rules', []);
654 9
        $name = $this->getNameKey();
655 9
        $messages = $this->getOption('error_messages', []);
656 9
        $formName = $this->formHelper->transformToDotSyntax($this->parent->getName());
657
658 9
        if ($messages && $formName) {
659 1
            $newMessages = [];
660 1
            foreach ($messages as $messageKey => $message) {
661 1
                $messageKey = sprintf('%s.%s', $formName, $messageKey);
662 1
                $newMessages[$messageKey] = $message;
663
            }
664 1
            $messages = $newMessages;
665
        }
666
667 9
        if (!$rules) {
668 2
            return [];
669
        }
670
671
        return [
672 8
            'rules' => [$name => $rules],
673 8
            'attributes' => [$name => $this->getOption('label')],
674 8
            'error_messages' => $messages
675
        ];
676
    }
677
678
    /**
679
     * Get this field's attributes, probably just one.
680
     *
681
     * @return array
682
     */
683 3
    public function getAllAttributes()
684
    {
685 3
        return [$this->getNameKey()];
686
    }
687
688
    /**
689
     * Get value property.
690
     *
691
     * @param mixed|null $default
692
     * @return mixed
693
     */
694 36
    public function getValue($default = null)
695
    {
696 36
        return $this->getOption($this->valueProperty, $default);
697
    }
698
699
    /**
700
     * Get default value property.
701
     *
702
     * @param mixed|null $default
703
     * @return mixed
704
     */
705 33
    public function getDefaultValue($default = null)
706
    {
707 33
        return $this->getOption($this->defaultValueProperty, $default);
708
    }
709
710
    /**
711
     * Check if provided value is valid for this type.
712
     *
713
     * @return bool
714
     */
715 91
    protected function isValidValue($value)
716
    {
717 91
        return $value !== null;
718
    }
719
720
    /**
721
     * Method initFilters used to initialize filters
722
     * from field options and bind it to the same.
723
     *
724
     * @return $this
725
     */
726 91
    protected function initFilters()
727
    {
728
        // If override status is set in field options to true
729
        // we will change filtersOverride property value to true
730
        // so we can override existing filters with registered
731
        // alias/name in addFilter method.
732 91
        $overrideStatus = $this->getOption('filters_override', false);
733 91
        if ($overrideStatus) {
734 2
            $this->setFiltersOverride(true);
735
        }
736
737
        // Get filters and bind it to field.
738 91
        $filters = $this->getOption('filters', []);
739 91
        foreach ($filters as $filter) {
740 8
            $this->addFilter($filter);
741
        }
742
743 91
        return $this;
744
    }
745
746
    /**
747
     * Method setFilters used to set filters to current filters property.
748
     *
749
     * @param  array $filters
750
     *
751
     * @return \Kris\LaravelFormBuilder\Fields\FormField
752
     */
753
    public function setFilters(array $filters)
754
    {
755
        $this->clearFilters();
756
        foreach ($filters as $filter) {
757
            $this->addFilter($filter);
758
        }
759
760
        return $this;
761
    }
762
763
    /**
764
     * Method getFilters returns array of binded filters
765
     * if there are any binded. Otherwise empty array.
766
     *
767
     * @return array
768
     */
769 23
    public function getFilters()
770
    {
771 23
        return $this->filters;
772
    }
773
774
    /**
775
     * @param  string|FilterInterface $filter
776
     *
777
     * @return \Kris\LaravelFormBuilder\Fields\FormField
778
     *
779
     * @throws FilterAlreadyBindedException
780
     */
781 8
    public function addFilter($filter)
782
    {
783
        // Resolve filter object from string/object or throw Ex.
784 8
        $filterObj = FilterResolver::instance($filter);
785
786
        // If filtersOverride is allowed we will override filter
787
        // with same alias/name if there is one with new resolved filter.
788 8
        if ($this->getFiltersOverride()) {
789 1
            if ($key = array_search($filterObj->getName(), $this->getFilters())) {
790
                $this->filters[$key] = $filterObj;
791
            } else {
792 1
                $this->filters[$filterObj->getName()] = $filterObj;
793
            }
794
        } else {
795
            // If filtersOverride is disabled and we found
796
            // equal alias defined we will throw Ex.
797 7
            if (array_key_exists($filterObj->getName(), $this->getFilters())) {
798 1
                $ex = new FilterAlreadyBindedException($filterObj->getName(), $this->getName());
799 1
                throw $ex;
800
            }
801
802
            // Filter with resolvedFilter alias/name doesn't exist
803
            // so we will bind it as new one to field.
804 7
            $this->filters[$filterObj->getName()] = $filterObj;
805
        }
806
807 8
        return $this;
808
    }
809
810
    /**
811
     * Method removeFilter used to remove filter by provided alias/name.
812
     *
813
     * @param  string $name
814
     *
815
     * @return \Kris\LaravelFormBuilder\Fields\FormField
816
     */
817 1
    public function removeFilter($name)
818
    {
819 1
        $filters = $this->getFilters();
820 1
        if (array_key_exists($name, $filters)) {
821 1
            unset($filters[$name]);
822 1
            $this->filters = $filters;
823
        }
824
825 1
        return $this;
826
    }
827
828
    /**
829
     * Method removeFilters used to remove filters by provided aliases/names.
830
     *
831
     * @param  array $filterNames
832
     *
833
     * @return \Kris\LaravelFormBuilder\Fields\FormField
834
     */
835 1
    public function removeFilters(array $filterNames)
836
    {
837 1
        $filters = $this->getFilters();
838 1
        foreach ($filterNames as $filterName) {
839 1
            if (array_key_exists($filterName, $filters)) {
840 1
                unset($filters[$filterName]);
841 1
                $this->filters = $filters;
842
            }
843
        }
844
845 1
        return $this;
846
    }
847
848
    /**
849
     * Method clearFilters used to empty current filters property.
850
     *
851
     * @return \Kris\LaravelFormBuilder\Fields\FormField
852
     */
853 1
    public function clearFilters()
854
    {
855 1
        $this->filters = [];
856 1
        return $this;
857
    }
858
859
    /**
860
     * Method used to set FiltersOverride status to provided value.
861
     *
862
     * @param $status
863
     *
864
     * @return \Kris\LaravelFormBuilder\Fields\FormField
865
     */
866 2
    public function setFiltersOverride($status)
867
    {
868 2
        $this->filtersOverride = $status;
869 2
        return $this;
870
    }
871
872
    /**
873
     * @return bool
874
     */
875 9
    public function getFiltersOverride()
876
    {
877 9
        return $this->filtersOverride;
878
    }
879
880
    /**
881
     * Method used to set Unfiltered/Unmutated field value.
882
     * Method is called before field value mutating starts - request value filtering.
883
     *
884
     * @param mixed $value
885
     *
886
     * @return \Kris\LaravelFormBuilder\Fields\FormField
887
     */
888 1
    public function setRawValue($value)
889
    {
890 1
        $this->rawValue = $value;
891 1
        return $this;
892
    }
893
894
    /**
895
     * Returns unfiltered raw value of field.
896
     *
897
     * @return mixed
898
     */
899
    public function getRawValue()
900
    {
901
        return $this->rawValue;
902
    }
903
}
904