-
Notifications
You must be signed in to change notification settings - Fork 824
/
FormField.php
1582 lines (1396 loc) · 41.9 KB
/
FormField.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<?php
namespace SilverStripe\Forms;
use LogicException;
use ReflectionClass;
use SilverStripe\Control\Controller;
use SilverStripe\Control\RequestHandler;
use SilverStripe\Core\ClassInfo;
use SilverStripe\Core\Convert;
use SilverStripe\ORM\DataObject;
use SilverStripe\ORM\DataObjectInterface;
use SilverStripe\ORM\FieldType\DBField;
use SilverStripe\ORM\FieldType\DBHTMLText;
use SilverStripe\ORM\ValidationResult;
use SilverStripe\View\AttributesHTML;
use SilverStripe\View\SSViewer;
/**
* Represents a field in a form.
*
* A FieldList contains a number of FormField objects which make up the whole of a form.
*
* In addition to single fields, FormField objects can be "composite", for example, the
* {@link TabSet} field. Composite fields let us define complex forms without having to resort to
* custom HTML.
*
* To subclass:
*
* Define a {@link dataValue()} method that returns a value suitable for inserting into a single
* database field.
*
* For example, you might tidy up the format of a date or currency field. Define {@link saveInto()}
* to totally customise saving.
*
* For example, data might be saved to the filesystem instead of the data record, or saved to a
* component of the data record instead of the data record itself.
*
* A form field can be represented as structured data through {@link FormSchema},
* including both structure (name, id, attributes, etc.) and state (field value).
* Can be used by for JSON data which is consumed by a front-end application.
*/
class FormField extends RequestHandler
{
use AttributesHTML;
use FormMessage;
/** @see $schemaDataType */
const SCHEMA_DATA_TYPE_STRING = 'String';
/** @see $schemaDataType */
const SCHEMA_DATA_TYPE_HIDDEN = 'Hidden';
/** @see $schemaDataType */
const SCHEMA_DATA_TYPE_TEXT = 'Text';
/** @see $schemaDataType */
const SCHEMA_DATA_TYPE_HTML = 'HTML';
/** @see $schemaDataType */
const SCHEMA_DATA_TYPE_INTEGER = 'Integer';
/** @see $schemaDataType */
const SCHEMA_DATA_TYPE_DECIMAL = 'Decimal';
/** @see $schemaDataType */
const SCHEMA_DATA_TYPE_MULTISELECT = 'MultiSelect';
/** @see $schemaDataType */
const SCHEMA_DATA_TYPE_SINGLESELECT = 'SingleSelect';
/** @see $schemaDataType */
const SCHEMA_DATA_TYPE_DATE = 'Date';
/** @see $schemaDataType */
const SCHEMA_DATA_TYPE_DATETIME = 'Datetime';
/** @see $schemaDataType */
const SCHEMA_DATA_TYPE_TIME = 'Time';
/** @see $schemaDataType */
const SCHEMA_DATA_TYPE_BOOLEAN = 'Boolean';
/** @see $schemaDataType */
const SCHEMA_DATA_TYPE_CUSTOM = 'Custom';
/** @see $schemaDataType */
const SCHEMA_DATA_TYPE_STRUCTURAL = 'Structural';
/**
* @var Form
*/
protected $form;
/**
* This is INPUT's type attribute value.
*
* @var string
*/
protected $inputType = 'text';
/**
* @var string
*/
protected $name;
/**
* @var null|string
*/
protected $title;
/**
* @var mixed
*/
protected $value;
/**
* @var string
*/
protected $extraClass;
/**
* Adds a title attribute to the markup.
*
* @var string
*
* @todo Implement in all subclasses
*/
protected $description;
/**
* Extra CSS classes for the FormField container.
*
* @var array
*/
protected $extraClasses;
/**
* @config
* @var array $default_classes The default classes to apply to the FormField
*/
private static $default_classes = [];
/**
* Right-aligned, contextual label for the field.
*
* @var string
*/
protected $rightTitle;
/**
* Left-aligned, contextual label for the field.
*
* @var string
*/
protected $leftTitle;
/**
* Stores a reference to the FieldList that contains this object.
*
* @var FieldList
*/
protected $containerFieldList;
/**
* @var bool
*/
protected $readonly = false;
/**
* @var bool
*/
protected $disabled = false;
/**
* @var bool
*/
protected $autofocus = false;
/**
* Custom validation message for the field.
*
* @var string
*/
protected $customValidationMessage = '';
/**
* @var Tip|null
*/
private $titleTip;
/**
* Name of the template used to render this form field. If not set, then will look up the class
* ancestry for the first matching template where the template name equals the class name.
*
* To explicitly use a custom template or one named other than the form field see
* {@link setTemplate()}.
*
* @var string
*/
protected $template;
/**
* Name of the template used to render this form field. If not set, then will look up the class
* ancestry for the first matching template where the template name equals the class name.
*
* To explicitly use a custom template or one named other than the form field see
* {@link setFieldHolderTemplate()}.
*
* @var string
*/
protected $fieldHolderTemplate;
/**
* @var string
*/
protected $smallFieldHolderTemplate;
/**
* The data type backing the field. Represents the type of value the
* form expects to receive via a postback. Should be set in subclasses.
*
* The values allowed in this list include:
*
* - String: Single line text
* - Hidden: Hidden field which is posted back without modification
* - Text: Multi line text
* - HTML: Rich html text
* - Integer: Whole number value
* - Decimal: Decimal value
* - MultiSelect: Select many from source
* - SingleSelect: Select one from source
* - Date: Date only
* - DateTime: Date and time
* - Time: Time only
* - Boolean: Yes or no
* - Custom: Custom type declared by the front-end component. For fields with this type,
* the component property is mandatory, and will determine the posted value for this field.
* - Structural: Represents a field that is NOT posted back. This may contain other fields,
* or simply be a block of stand-alone content. As with 'Custom',
* the component property is mandatory if this is assigned.
*
* Each value has an equivalent constant, e.g. {@link self::SCHEMA_DATA_TYPE_STRING}.
*
* @var string
*/
protected $schemaDataType;
/**
* The type of front-end component to render the FormField as.
*
* @var string
*/
protected $schemaComponent;
/**
* Structured schema data representing the FormField.
* Used to render the FormField as a ReactJS Component on the front-end.
*
* @var array
*/
protected $schemaData = [];
private static $casting = [
'FieldHolder' => 'HTMLFragment',
'SmallFieldHolder' => 'HTMLFragment',
'Field' => 'HTMLFragment',
'AttributesHTML' => 'HTMLFragment', // property $AttributesHTML version
'getAttributesHTML' => 'HTMLFragment', // method $getAttributesHTML($arg) version
'Value' => 'Text',
'extraClass' => 'Text',
'ID' => 'Text',
'isReadOnly' => 'Boolean',
'HolderID' => 'Text',
'Title' => 'Text',
'RightTitle' => 'Text',
'Description' => 'HTMLFragment',
];
/**
* Structured schema state representing the FormField's current data and validation.
* Used to render the FormField as a ReactJS Component on the front-end.
*
* @var array
*/
protected $schemaState = [];
/**
* Takes a field name and converts camelcase to spaced words. Also resolves combined field
* names with dot syntax to spaced words.
*
* Examples:
*
* - 'TotalAmount' will return 'Total amount'
* - 'Organisation.ZipCode' will return 'Organisation zip code'
*
* @param string $fieldName
*
* @return string
*/
public static function name_to_label($fieldName)
{
// Handle dot delimiters
if (strpos($fieldName ?? '', '.') !== false) {
$parts = explode('.', $fieldName ?? '');
// Ensure that any letter following a dot is uppercased, so that the regex below can break it up
// into words
$label = implode(array_map('ucfirst', $parts ?? []));
} else {
$label = $fieldName;
}
// Replace any capital letter that is followed by a lowercase letter with a space, the lowercased
// version of itself then the remaining lowercase letters.
$labelWithSpaces = preg_replace_callback('/([A-Z])([a-z]+)/', function ($matches) {
return ' ' . strtolower($matches[1] ?? '') . $matches[2];
}, $label ?? '');
// Add a space before any capital letter block that is at the end of the string
$labelWithSpaces = preg_replace('/([a-z])([A-Z]+)$/', '$1 $2', $labelWithSpaces ?? '');
// The first letter should be uppercase
return ucfirst(trim($labelWithSpaces ?? ''));
}
/**
* Creates a new field.
*
* @param string $name The internal field name, passed to forms.
* @param null|string|\SilverStripe\View\ViewableData $title The human-readable field label.
* @param mixed $value The value of the field.
*/
public function __construct($name, $title = null, $value = null)
{
$this->setName($name);
if ($title === null) {
$this->title = self::name_to_label($name);
} else {
$this->title = $title;
}
if ($value !== null) {
$this->setValue($value);
}
parent::__construct();
$this->setupDefaultClasses();
}
/**
* Set up the default classes for the form. This is done on construct so that the default classes can be removed
* after instantiation
*/
protected function setupDefaultClasses()
{
$defaultClasses = $this->config()->get('default_classes');
if ($defaultClasses) {
foreach ($defaultClasses as $class) {
$this->addExtraClass($class);
}
}
}
/**
* Return a link to this field
*
* @param string $action
* @return string
* @throws LogicException If no form is set yet
*/
public function Link($action = null)
{
if (!$this->form) {
throw new LogicException(
'Field must be associated with a form to call Link(). Please use $field->setForm($form);'
);
}
$link = Controller::join_links($this->form->FormAction(), 'field/' . $this->name, $action);
$this->extend('updateLink', $link, $action);
return $link;
}
/**
* Returns the HTML ID of the field.
*
* The ID is generated as FormName_FieldName. All Field functions should ensure that this ID is
* included in the field.
*
* @return string
*/
public function ID()
{
return $this->getTemplateHelper()->generateFieldID($this);
}
/**
* Returns the HTML ID for the form field holder element.
*
* @return string
*/
public function HolderID()
{
return $this->getTemplateHelper()->generateFieldHolderID($this);
}
/**
* Returns the current {@link FormTemplateHelper} on either the parent
* Form or the global helper set through the {@link Injector} layout.
*
* To customize a single {@link FormField}, use {@link setTemplate} and
* provide a custom template name.
*
* @return FormTemplateHelper
*/
public function getTemplateHelper()
{
if ($this->form) {
return $this->form->getTemplateHelper();
}
return FormTemplateHelper::singleton();
}
/**
* Returns the field name.
*
* @return string
*/
public function getName()
{
return $this->name;
}
/**
* Returns the field input name.
*
* @return string
*/
public function getInputType()
{
return $this->inputType;
}
/**
* Returns the field value.
*
* @see FormField::setSubmittedValue()
* @return mixed
*/
public function Value()
{
return $this->value;
}
/**
* Method to save this form field into the given {@link DataObject}.
*
* By default, makes use of $this->dataValue()
*
* @param DataObject|DataObjectInterface $record DataObject to save data into
*/
public function saveInto(DataObjectInterface $record)
{
$component = $record;
$fieldName = $this->name;
// Allow for dot syntax
if (($pos = strrpos($this->name ?? '', '.')) !== false) {
$relation = substr($this->name ?? '', 0, $pos);
$fieldName = substr($this->name ?? '', $pos + 1);
$component = $record->relObject($relation);
}
if ($fieldName && $component) {
$component->setCastedField($fieldName, $this->dataValue());
} else {
$record->setCastedField($this->name, $this->dataValue());
}
}
/**
* Returns the field value suitable for insertion into the data object.
* @see Formfield::setValue()
* @return mixed
*/
public function dataValue()
{
return $this->value;
}
/**
* Returns the field label - used by templates.
*
* @return string
*/
public function Title()
{
return $this->title;
}
/**
* Set the title of this formfield.
* Note: This expects escaped HTML.
*
* @param string $title Escaped HTML for title
* @return $this
*/
public function setTitle($title)
{
$this->title = $title;
return $this;
}
/**
* Gets the contextual label than can be used for additional field description.
* Can be shown to the right or under the field in question.
*
* @return string Contextual label text
*/
public function RightTitle()
{
return $this->rightTitle;
}
/**
* Sets the right title for this formfield
*
* @param string|DBField $rightTitle Plain text string, or a DBField with appropriately escaped HTML
* @return $this
*/
public function setRightTitle($rightTitle)
{
$this->rightTitle = $rightTitle;
return $this;
}
/**
* @return string
*/
public function LeftTitle()
{
return $this->leftTitle;
}
/**
* @param string $leftTitle
*
* @return $this
*/
public function setLeftTitle($leftTitle)
{
$this->leftTitle = $leftTitle;
return $this;
}
/**
* Compiles all CSS-classes. Optionally includes a "form-group--no-label" class if no title was set on the
* FormField.
*
* Uses {@link Message()} and {@link MessageType()} to add validation error classes which can
* be used to style the contained tags.
*
* @return string
*/
public function extraClass()
{
$classes = [];
$classes[] = $this->Type();
if ($this->extraClasses) {
$classes = array_merge(
$classes,
array_values($this->extraClasses ?? [])
);
}
if (!$this->Title()) {
$classes[] = 'form-group--no-label';
}
// Allow custom styling of any element in the container based on validation errors,
// e.g. red borders on input tags.
//
// CSS class needs to be different from the one rendered through {@link FieldHolder()}.
if ($this->getMessage()) {
$classes[] = 'holder-' . $this->getMessageType();
}
return implode(' ', $classes);
}
/**
* Check if a CSS-class has been added to the form container.
*
* @param string $class A string containing a classname or several class
* names delimited by a single space.
* @return boolean True if all of the classnames passed in have been added.
*/
public function hasExtraClass($class)
{
//split at white space
$classes = preg_split('/\s+/', $class ?? '');
foreach ($classes as $class) {
if (!isset($this->extraClasses[$class])) {
return false;
}
}
return true;
}
/**
* Add one or more CSS-classes to the FormField container.
*
* Multiple class names should be space delimited.
*
* @param string $class
*
* @return $this
*/
public function addExtraClass($class)
{
$classes = preg_split('/\s+/', $class ?? '');
foreach ($classes as $class) {
$this->extraClasses[$class] = $class;
}
return $this;
}
/**
* Remove one or more CSS-classes from the FormField container.
*
* @param string $class
*
* @return $this
*/
public function removeExtraClass($class)
{
$classes = preg_split('/\s+/', $class ?? '');
foreach ($classes as $class) {
unset($this->extraClasses[$class]);
}
return $this;
}
protected function getDefaultAttributes(): array
{
$attributes = [
'type' => $this->getInputType(),
'name' => $this->getName(),
'value' => $this->Value(),
'class' => $this->extraClass(),
'id' => $this->ID(),
'disabled' => $this->isDisabled(),
'readonly' => $this->isReadonly(),
'autofocus' => $this->isAutofocus()
];
if ($this->Required()) {
$attributes['required'] = 'required';
$attributes['aria-required'] = 'true';
}
return $attributes;
}
/**
* Returns a version of a title suitable for insertion into an HTML attribute.
*
* @return string
*/
public function attrTitle()
{
return Convert::raw2att($this->title);
}
/**
* Returns a version of a title suitable for insertion into an HTML attribute.
*
* @return string
*/
public function attrValue()
{
return Convert::raw2att($this->value);
}
/**
* Set the field value.
*
* If a FormField requires specific behaviour for loading content from either the database
* or a submitted form value they should override setSubmittedValue() instead.
*
* @param mixed $value Either the parent object, or array of source data being loaded
* @param array|DataObject $data {@see Form::loadDataFrom}
* @return $this
*/
public function setValue($value, $data = null)
{
$this->value = $value;
return $this;
}
/**
* Set value assigned from a submitted form postback.
* Can be overridden to handle custom behaviour for user-localised
* data formats.
*
* @param mixed $value
* @param array|DataObject $data
* @return $this
*/
public function setSubmittedValue($value, $data = null)
{
return $this->setValue($value, $data);
}
/**
* Set the field name.
*
* @param string $name
*
* @return $this
*/
public function setName($name)
{
$this->name = $name;
return $this;
}
/**
* Set the field input type.
*
* @param string $type
*
* @return $this
*/
public function setInputType($type)
{
$this->inputType = $type;
return $this;
}
/**
* Set the container form.
*
* This is called automatically when fields are added to forms.
*
* @param Form $form
*
* @return $this
*/
public function setForm($form)
{
$this->form = $form;
return $this;
}
/**
* Get the currently used form.
*
* @return Form
*/
public function getForm()
{
return $this->form;
}
/**
* Return true if security token protection is enabled on the parent {@link Form}.
*
* @return bool
*/
public function securityTokenEnabled()
{
$form = $this->getForm();
if (!$form) {
return false;
}
return $form->getSecurityToken()->isEnabled();
}
public function castingHelper($field)
{
// Override casting for field message
if (strcasecmp($field ?? '', 'Message') === 0 && ($helper = $this->getMessageCastingHelper())) {
return $helper;
}
return parent::castingHelper($field);
}
/**
* Set the custom error message to show instead of the default format.
*
* Different from setError() as that appends it to the standard error messaging.
*
* @param string $customValidationMessage
*
* @return $this
*/
public function setCustomValidationMessage($customValidationMessage)
{
$this->customValidationMessage = $customValidationMessage;
return $this;
}
/**
* Get the custom error message for this form field. If a custom message has not been defined
* then just return blank. The default error is defined on {@link Validator}.
*
* @return string
*/
public function getCustomValidationMessage()
{
return $this->customValidationMessage;
}
/**
* Set name of template (without path or extension).
*
* Caution: Not consistently implemented in all subclasses, please check the {@link Field()}
* method on the subclass for support.
*
* @param string $template
*
* @return $this
*/
public function setTemplate($template)
{
$this->template = $template;
return $this;
}
/**
* @return string
*/
public function getTemplate()
{
return $this->template;
}
/**
* @return string
*/
public function getFieldHolderTemplate()
{
return $this->fieldHolderTemplate;
}
/**
* Set name of template (without path or extension) for the holder, which in turn is
* responsible for rendering {@link Field()}.
*
* Caution: Not consistently implemented in all subclasses, please check the {@link Field()}
* method on the subclass for support.
*
* @param string $fieldHolderTemplate
*
* @return $this
*/
public function setFieldHolderTemplate($fieldHolderTemplate)
{
$this->fieldHolderTemplate = $fieldHolderTemplate;
return $this;
}
/**
* @return string
*/
public function getSmallFieldHolderTemplate()
{
return $this->smallFieldHolderTemplate;
}
/**
* Set name of template (without path or extension) for the small holder, which in turn is
* responsible for rendering {@link Field()}.
*
* Caution: Not consistently implemented in all subclasses, please check the {@link Field()}
* method on the subclass for support.
*
* @param string $smallFieldHolderTemplate
*
* @return $this
*/
public function setSmallFieldHolderTemplate($smallFieldHolderTemplate)
{
$this->smallFieldHolderTemplate = $smallFieldHolderTemplate;
return $this;
}
/**
* Returns the form field.
*
* Although FieldHolder is generally what is inserted into templates, all of the field holder
* templates make use of $Field. It's expected that FieldHolder will give you the "complete"
* representation of the field on the form, whereas Field will give you the core editing widget,
* such as an input tag.
*
* @param array $properties
* @return DBHTMLText
*/
public function Field($properties = [])
{
$context = $this;
$this->extend('onBeforeRender', $context, $properties);
if (count($properties ?? [])) {
$context = $context->customise($properties);
}
$result = $context->renderWith($context->getTemplates());
// Trim whitespace from the result, so that trailing newlines are suppressed. Works for strings and HTMLText values
if (is_string($result)) {
$result = trim($result ?? '');
} elseif ($result instanceof DBField) {
$result->setValue(trim($result->getValue() ?? ''));
}
return $result;
}
/**
* Returns a "field holder" for this field.
*
* Forms are constructed by concatenating a number of these field holders.
*
* The default field holder is a label and a form field inside a div.
*
* @see FieldHolder.ss
*
* @param array $properties
*
* @return DBHTMLText
*/
public function FieldHolder($properties = [])
{
$context = $this;
$this->extend('onBeforeRenderHolder', $context, $properties);
if (count($properties ?? [])) {
$context = $context->customise($properties);
}
return $context->renderWith($context->getFieldHolderTemplates());
}
/**
* Returns a restricted field holder used within things like FieldGroups.
*
* @param array $properties
*
* @return string
*/
public function SmallFieldHolder($properties = [])
{
$context = $this;
if (count($properties ?? [])) {
$context = $this->customise($properties);
}
return $context->renderWith($this->getSmallFieldHolderTemplates());
}
/**
* Returns an array of templates to use for rendering {@link FieldHolder}.
*
* @return array
*/
public function getTemplates()
{
return $this->_templates($this->getTemplate());
}
/**
* Returns an array of templates to use for rendering {@link FieldHolder}.
*
* @return array
*/
public function getFieldHolderTemplates()