/
InputfieldRepeater.module
746 lines (644 loc) · 21.9 KB
/
InputfieldRepeater.module
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
<?php
/**
* ProcessWire Repeater Inputfield
*
* Maintains a collection of fields that are repeated for any number of times.
*
* ProcessWire 2.8.x, Copyright 2016 by Ryan Cramer
* https://processwire.com
*
* @property int $repeaterMaxItems
*
* @method string renderRepeaterLabel($label, $cnt, Page $page)
*
*
*/
class InputfieldRepeater extends Inputfield implements InputfieldItemList {
public static function getModuleInfo() {
return array(
'title' => __('Repeater', __FILE__), // Module Title
'summary' => __('Repeats fields from another template. Provides the input for FieldtypeRepeater.', __FILE__), // Module Summary
'version' => 105,
'requires' => 'FieldtypeRepeater',
);
}
/**
* Array of InputfieldWrapper objects indexed by repeater page ID
*
*/
protected $wrappers = array();
/**
* Array of text labels indexed by repeater page ID
*
*/
protected $labels = array();
/**
* The page that the repeaters field lives on, set by FieldtypeRepeater::getInputfield
*
* @var Page
*
*/
protected $page;
/**
* The field this InputfieldRepeater is serving, set by FieldtypeRepeater::getInputfield
*
* @var Field
*
*/
protected $field;
/**
* Cached form containing the repeaters
*
* @var InputfieldWrapper
*
*/
protected $form;
/**
* All Inputfield classes (strings) used by the Inputfield
*
* @var array
*
*/
protected $inputfieldClasses = array();
/**
* Are we currently in render value mode? (i.e. render values, but not inputs)
*
* @var bool
*
*/
protected $renderValueMode = false;
/**
* Set config defaults
*
*/
public function __construct() {
parent::__construct();
// these are part of the Fieldtype's config, and automatically set from it
$this->set('repeaterMaxItems', 0);
}
/**
* Initialize the repeaters inputfield
*
*/
public function init() {
parent::init();
if(is_null($this->page)) $this->page = $this->wire('pages')->newNullPage();
$this->attr('value', $this->wire('pages')->newPageArray());
}
/**
* Render the repeater label
*
* @param string $label Default label
* @param int $cnt Item index (1-based)
* @param Page $page Repeater item
* @return string
*
*/
public function ___renderRepeaterLabel($label, $cnt, Page $page) {
$out = '';
$repeaterTitle = $this->field ? $this->field->get('repeaterTitle') : '';
if($page->id && $repeaterTitle) {
// custom repeater titles specified
if($this->wire('sanitizer')->fieldName($repeaterTitle) === $repeaterTitle) {
// just a single field name
$value = $page->getFormatted($repeaterTitle);
if(is_object($value)) {
if($value instanceof Page) {
$out = $value->get('title|name');
} else if($value instanceof PageArray) {
$out = $value->implode(', ');
} else {
$out = (string) $value;
}
}
} else if(strpos($repeaterTitle, '{') !== false) {
// formatted {label}
$out = $page->getMarkup($repeaterTitle);
} else {
// label, but with no page variables
$out = $repeaterTitle;
}
$out = strip_tags(trim($out));
// update index numbers?
if(stripos($out, '#n') !== false) {
// replace "#n" with index number of repeater item
$out = preg_replace('/#n\b/i', "#$cnt", $out);
} else {
// otherwise remove any pound signs so the JS side doesn't detect them
$out = str_replace('#', '', $out);
}
}
if(!strlen($out)) {
// fallback to default
if(!strlen($label)) $label = $this->field->getLabel();
$out = "$label #" . $cnt;
}
// note {brackets} surround text that will be visually muted from the JS side
if(!$page->id) {
// non-editable new item
$out .= ' {• ' . $this->_('This item will become editable after you save.') . '}';
} else if($page->isUnpublished() && $page->hasStatus(Page::statusOn)) {
// editable new item
$out .= ' {• ' . $this->_('New') . '}';
}
$maxlen = 100;
if(strlen($out) > $maxlen) {
$out = substr($out, 0, $maxlen);
$pos = strrpos($out, ' ');
if($pos > ($maxlen / 2)) $out = substr($out, 0, $pos);
}
return $out;
}
/**
* Get the repeater item type (if used)
*
* @param Page $page
* @return int
*
*/
protected function getRepeaterItemType(Page $page) {
if($page) {}
return 1;
}
/**
* Preload all assets used by Inputfields of this type
*
* This ensures all required JS/CSS files are loaded in the original/non-ajax request.
* This should be called only when needed, like if there are 0 items in the repeater
* when ajax-add support enabled.
*
* @param array $fieldIDs Optionally specify the IDs of the Field objects you want to limit preload to.
*
*/
protected function preloadInputfieldAssets($fieldIDs = array()) {
if(empty($fieldIDs)) $fieldIDs = $this->field->get('repeaterFields');
if(!is_array($fieldIDs)) return;
foreach($fieldIDs as $fieldID) {
$field = $this->wire('fields')->get($fieldID);
try {
// the following forces assets to be loaded
$inputfield = $field->getInputfield($this->page);
if($inputfield) $inputfield->renderReady(null, false);
} catch(\Exception $e) {
$this->warning("Repeater '$this->name' preload '$field': " . $e->getMessage(), Notice::debug);
}
}
}
/**
* Get Inputfields for the given repeater item
*
* @param Page $page
* @return InputfieldWrapper
*
*/
protected function getRepeaterItemInputfields(Page $page) {
return $page->template->fieldgroup->getPageInputfields($page, "_repeater{$page->id}");
}
/**
* Build the form containing the repeaters
*
* @param int $itemID Build form for only this item (optional)
* @param array|null $loadInputsForIDs If array specified, load inputs for the custom page fields into the form for only these page IDs
* @return InputfieldWrapper
* @throws WireException if $this->page or $this->field are set incorrectly
*
*/
protected function buildForm($itemID = 0, $loadInputsForIDs = null) {
// if it's already been built, then return the cached version
if(!is_null($this->form)) return $this->form;
// if required fields don't exist then exit
if(!$this->field || !$this->field->type instanceof FieldtypeRepeater) {
throw new WireException("You must set a 'field' (type Field) property to {$this->className} of FieldtypeRepeater");
}
if(!$this->page || !$this->page->id) {
throw new WireException("You must set a 'page' (type Page) property to {$this->className} with repeater field '$this->name'");
}
/** @var InputfieldWrapper $form */
$form = $this->wire(new InputfieldWrapper());
$form->name = 'repeater_form_' . $this->name . ($itemID ? "_$itemID" : "");
$this->wrapAttr('data-page', $this->page->id);
/** @var PageArray $value */
$value = $this->attr('value');
// get field label in user's language if available
$label = $this->field->getLabel();
if(!$label) $label = ucfirst($this->field->name);
// remember which repeater items are open, when enabled
if((int) $this->field->get('rememberOpen')) {
$this->addClass('InputfieldRepeaterRememberOpen', 'wrapClass');
$openIDs = $this->wire('input')->cookie('repeaters_open');
if($openIDs) $openIDs = explode('|', trim($openIDs, '|'));
if(!is_array($openIDs)) $openIDs = array();
} else {
$openIDs = array();
}
$repeaterCollapse = (int) $this->field->get('repeaterCollapse');
$cnt = 0;
// create field for each repeater iteration
foreach($value as $key => $page) {
if($itemID && $page->id != $itemID) continue;
/** @var Page $page */
$isUnpublished = $page->isUnpublished();
$isHidden = $page->isHidden();
$isOn = $page->hasStatus(Page::statusOn);
$isReadyItem = $isHidden && $isUnpublished;
$isOpen = in_array($page->id, $openIDs);
// get the inputfields for the repeater page
if(is_null($loadInputsForIDs) || in_array($page->id, $loadInputsForIDs) || $isOpen) {
$inputfields = $this->getRepeaterItemInputfields($page);
$isLoaded = true;
} else {
$inputfields = new InputfieldWrapper(); // non loaded
$isLoaded = false;
}
$inputfields->set('useDependencies', false);
$this->wrappers[$page->id] = $inputfields;
// also add a delete checkbox to the repeater page fields
$delete = $this->wire('modules')->get('InputfieldCheckbox');
$delete->attr('id+name', "delete_repeater{$page->id}");
$delete->class = 'InputfieldRepeaterDelete';
$delete->label = $this->_('Delete');
$delete->attr('value', $page->id);
$sort = $this->wire('modules')->get('InputfieldHidden');
$sort->attr('id+name', "sort_repeater{$page->id}");
$sort->class = 'InputfieldRepeaterSort';
$sort->label = $this->_('Sort');
$sort->attr('value', $cnt);
$loaded = $this->wire('modules')->get('InputfieldHidden');
$loaded->attr('id+name', "loaded_repeater{$page->id}");
$loaded->class = 'InputfieldRepeaterLoaded';
$loaded->attr('value', $isLoaded ? 1 : 0);
$wrap = $this->wire('modules')->get('InputfieldFieldset');
$wrap->addClass('InputfieldRepeaterItem');
$wrap->label = $this->renderRepeaterLabel($label, ++$cnt, $page);
$wrap->name = "repeater_item_{$page->id}";
$wrap->wrapAttr('data-page', $page->id);
$wrap->wrapAttr('data-type', $this->getRepeaterItemType($page));
$wrap->wrapAttr('data-editUrl', $page->editUrl()); // if needed by any Inputfields within like InputfieldFile/InputfieldImage
$wrap->set('useDependencies', false);
if($isOpen) {
$wrap->collapsed = Inputfield::collapsedNo;
} else if($repeaterCollapse == FieldtypeRepeater::collapseExisting && !$page->get('_repeater_new') && !$isHidden) {
$wrap->collapsed = Inputfield::collapsedYes;
} else if($repeaterCollapse == FieldtypeRepeater::collapseAll) {
$wrap->collapsed = Inputfield::collapsedYes;
}
$hasErrors = count($inputfields->getErrors()) > 0;
if($hasErrors) $wrap->icon = 'warning';
// add a hidden field that will be populated with a positive value for all visible repeater items
// this is so that processInput can see this item should be a published item
$f = $this->wire('modules')->get('InputfieldHidden');
$f->attr('name', "publish_repeater{$page->id}");
$f->attr('class', 'InputfieldRepeaterPublish');
if($isReadyItem) {
// ready item
$f->attr('value', 0);
} else if($isUnpublished && !$isOn) {
// unpublished item
$f->attr('value', -1);
} else {
// published item
$f->attr('value', 1);
}
$wrap->add($f);
if($isUnpublished) {
$wrap->addClass('InputfieldRepeaterUnpublished');
if(!$isOn) $wrap->addClass('InputfieldRepeaterOff');
}
$wrap->add($inputfields);
$wrap->prepend($delete);
$wrap->prepend($sort);
$wrap->prepend($loaded);
if(!$isReadyItem) $form->add($wrap);
$this->labels[$page->id] = $wrap->getSetting('label');
}
// create a new/blank item to be used as a template for any new items added
$wrap = $this->wire('modules')->get('InputfieldFieldset');
$wrap->label = $this->renderRepeaterLabel($label, ++$cnt, new NullPage());
$wrap->class = 'InputfieldRepeaterItem InputfieldRepeaterNewItem';
$wrap->collapsed = Inputfield::collapsedNo;
$form->add($wrap);
// cache
$this->form = $form;
return $form;
}
/**
* Get next page ready to be used as new item
*
* @param array $notIDs Page IDs that we won't allow for the new item (because already rendered)
* @return Page
*
*/
protected function getNextReadyPage(array $notIDs) {
/** @var FieldtypeRepeater $fieldtype */
$fieldtype = $this->field->type;
/** @var PageArray $value */
$value = $this->attr('value');
$readyPage = $fieldtype->getNextReadyPage($this->page, $this->field, $value, $notIDs);
return $readyPage;
}
/**
* Render a new item for ajax after 'add new' link clicked
*
* @return string
*
*/
public function renderAjaxNewItem() {
/** @var PageArray $value */
$value = $this->attr('value');
$notIDs = $this->wire('sanitizer')->intArray(explode(',', trim($this->wire('input')->get('repeater_not'), ',')));
$readyPage = $this->getNextReadyPage($notIDs);
$readyPage->removeStatus(Page::statusHidden);
// ensure editing page doesn't get saved (just in case) since we're removing all items
$this->page->addStatus(Page::statusCorrupted);
$value->add($readyPage);
return $this->buildForm($readyPage->id)->render();
}
/**
* Render the "add new" repeater label
*
* @return mixed|string
* @throws WireException
*
*/
protected function renderAddLabel() {
$addLabel = $this->field->get('repeaterAddLabel');
if($this->wire('languages')) {
$language = $this->wire('user')->language;
if(!$language->isDefault()) {
$addLabel = $this->field->get("repeaterAddLabel$language");
}
}
if(!strlen($addLabel)) $addLabel = $this->_('Add New');
return $addLabel;
}
/**
* Called before render() or renderValue() method by InputfieldWrapper, before Inputfield-specific CSS/JS files added
*
* @param Inputfield|InputfieldWrapper|null The parent Inputfield/wrapper that is rendering it or null if no parent.
* @param bool $renderValueMode Whether renderValueMode will be used.
* @return bool
*
*/
public function renderReady(Inputfield $parent = null, $renderValueMode = false) {
$this->wire('modules')->get('JqueryCore')->use('cookie');
$this->preloadInputfieldAssets();
return parent::renderReady($parent, $renderValueMode);
}
/**
* Render the footer of the repeater items, which is the "add new" item section
*
* @param string $noAjaxAdd Value is '1' if AJAX-adding is disallowed, or blank if it's allowed
* @return string
*
*/
protected function renderFooter($noAjaxAdd) {
// a hidden checkbox with link that we use to identify when items have been added
$out =
"<p class='InputfieldRepeaterAddItem'>" .
"<input class='InputfieldRepeaterAddItemsQty' type='text' name='_{$this->name}_add_items' value='0' />" . // for noAjaxAdd
"<a href='#' data-type='1' class='InputfieldRepeaterAddLink' data-noajax='$noAjaxAdd'>" .
"<i class='fa fa-fw fa-plus-circle InputfieldRepeaterSpinner' " .
"data-on='fa-spin fa-spinner' data-off='fa-plus-circle'></i>" .
$this->renderAddLabel() .
"</a>" .
"</p>";
return $out;
}
/**
* Render the repeater items
*
* @return string
*
*/
public function ___render() {
$input = $this->wire('input');
$noAjaxAdd = $this->field->get('repeaterLoading') == FieldtypeRepeater::loadingOff ? '1' : '';
$ajax = $this->wire('config')->ajax;
if($ajax && $input->get('field') == $this->attr('name')) {
$repeaterAdd = $input->get('repeater_add');
$repeaterEdit = (int) $input->get('repeater_edit');
if($repeaterAdd !== null && !$noAjaxAdd) {
return $this->renderValueMode ? '' : $this->renderAjaxNewItem();
} else if($repeaterEdit) {
if($this->renderValueMode) {
return $this->buildForm($repeaterEdit)->renderValue();
} else {
return $this->buildForm($repeaterEdit)->render();
}
}
}
$out = $this->renderValueMode ? '' : $this->renderFooter($noAjaxAdd);
$loading = $this->field->get('repeaterLoading');
$collapse = $this->field->get('repeaterCollapse');
$forIDs = null;
if($loading == FieldtypeRepeater::loadingAll && $collapse != FieldtypeRepeater::collapseNone) $forIDs = array();
list($editorUrl, $queryString) = explode('?', $this->page->editUrl());
$this->wire('config')->js('InputfieldRepeater', array(
'editorUrl' => $editorUrl,
'labels' => array(
'remove' => $this->_x('Delete this item', 'repeater-item-action'),
'toggle' => $this->_x('Toggle published/unpublished', 'repeater-item-action')
)
));
return $this->buildForm(0, $forIDs)->render() . $out;
}
/**
* Render value (no inputs)
*
* @return string
*
*/
public function ___renderValue() {
$flags = $this->getSetting('renderValueFlags');
if($flags & Inputfield::renderValueMinimal) {
$out = parent::___renderValue();
} else {
$this->renderValueMode = true;
$out = $this->render();
$this->renderValueMode = false;
}
return $out;
}
/**
* Process the input from a submitted repeaters field
*
* @param WireInputData $input
* @return $this
*
*/
public function ___processInput(WireInputData $input) {
/** @var PageArray $value */
$value = $this->attr('value');
$loadedIDs = array();
// determine which repeater pages have data posted in this request
foreach($value as $key => $page) {
$loadedName = "loaded_repeater$page->id";
if(((int) $input->$loadedName) > 0) $loadedIDs[$page->id] = $page->id;
}
$this->buildForm(0, $loadedIDs);
$numChanges = 0;
$sortChanged = false;
$value->setTrackChanges(true);
$pageIDs = array();
// existing items
foreach($value as $key => $page) {
/** @var Page $page */
$pageIDs[] = $page->id;
$isHidden = $page->isHidden();
$isUnpublished = $page->isUnpublished();
$isOn = $page->hasStatus(Page::statusOn);
$deleteName = "delete_repeater{$page->id}";
$sortName = "sort_repeater{$page->id}";
$publishName = "publish_repeater{$page->id}";
if($input->$deleteName == $page->id) {
$value->remove($page);
$numChanges++;
continue;
}
$sort = $input->$sortName;
// skip pages that don't appear in the POST data (most likely ready pages)
if(is_null($sort)) continue;
$page->sort = (int) $sort;
if($page->isChanged('sort')) {
// $this->message("Sort changed for field {$this->field} page {$page->id}", Notice::debug);
$sortChanged = true;
}
/** @var InputfieldWrapper $wrapper */
$wrapper = $this->wrappers[$page->id];
$wrapper->resetTrackChanges(true);
$wrapper->processInput($input);
$numErrors = count($wrapper->getErrors());
$page->setQuietly('_repeater_errors', $numErrors); // signal to FieldtypeRepeater::savePageField() that page has errors
$page->setQuietly('_repeater_processed', true); // signal to FieldtypeRepeater::savePageField() that page had input processed
$this->formToPage($wrapper, $page);
$publish = (int) $input->$publishName;
if($publish > 0 && ($isHidden || $isUnpublished)) {
// publish requested (publish=1)
if($isHidden) $page->removeStatus(Page::statusHidden);
if(!$numErrors && $isUnpublished) $page->removeStatus(Page::statusUnpublished);
if(!$isOn) $page->addStatus(Page::statusOn);
} else if($publish < 0) {
// unpublish requested (publish=-1)
if($isOn) $page->removeStatus(Page::statusOn);
if($isHidden) $page->removeStatus(Page::statusHidden);
if(!$isUnpublished) $page->addStatus(Page::statusUnpublished);
} else if(!$isOn) {
// no publish change requested, just ensure page is on
$page->addStatus(Page::statusOn);
}
if($page->isChanged() && $this->page->id) $numChanges++;
}
// if the sort changed, then tell the PageArray to sort by _repeater_sort
if($sortChanged) {
$this->value->sort('sort');
$numChanges++;
}
if($this->field->get('repeaterLoading') == FieldtypeRepeater::loadingOff) {
$numNewItems = (int) $input["_{$this->name}_add_items"];
if($numNewItems) {
// iterate through each new item added for non-ajax mode
for($n = 0; $n < $numNewItems; $n++) {
$page = $this->getNextReadyPage($pageIDs);
$page->removeStatus(Page::statusHidden);
$page->sort = count($value);
$value->add($page);
$numChanges++;
}
}
}
// if changes occurred, then tell $this->page and the PageArray $value
if($numChanges) {
$this->page->trackChange($this->attr('name'));
$this->trackChange('value');
}
return $this;
}
/**
* Take a form (InputfieldWrapper) and map the data to a Page that has the same fields
*
* @todo potentially convert this to it's own FormToPage class to avoid duplication between this as ProcessPageEdit
*
* @param InputfieldWrapper $wrapper
* @param Page $page
* @param int $level
*
*/
protected function formToPage(InputfieldWrapper $wrapper, Page $page, $level = 0) {
$languages = $this->wire('languages');
foreach($wrapper as $inputfield) {
$name = $inputfield->attr('name');
$name = preg_replace('/_repeater\d+$/', '', $name);
if($name && $inputfield->isChanged()) {
if($languages && $inputfield->getSetting('useLanguages')) {
$value = $page->get($name);
if(is_object($value)) {
$value->setFromInputfield($inputfield);
$page->set($name, $value);
}
} else {
$value = $inputfield->attr('value');
$page->set($name, $value);
}
if($page->isChanged($name)) {
// if a 'ready' page was changed, then we may now consider it a regular repeater page
if($page->hasStatus(Page::statusHidden)) $page->removeStatus(Page::statusHidden);
}
}
if($inputfield instanceof InputfieldWrapper && count($inputfield->getChildren())) {
$this->formToPage($inputfield, $page, $level + 1);
}
}
}
/**
* Returns whether any values are present
*
* @return bool
*
*/
public function isEmpty() {
/** @var PageArray $value */
$value = $this->attr('value');
if(count($value) == 0) return true;
$cnt = 0;
foreach($value as $item) {
if($item->hasStatus(Page::statusHidden) && $item->hasStatus(Page::statusUnpublished)) continue;
$cnt++;
}
return $cnt === 0;
}
/**
* Override the default set() to capture the required $page variable that the repeaters field lives on.
*
* @param string $key
* @param mixed $value
* @return $this
*
*/
public function set($key, $value) {
if($key == 'page') $this->page = $value;
else if($key == 'field') $this->field = $value;
else return parent::set($key, $value);
return $this;
}
/**
* Get the repeater wrappers (InputfieldWrappers) indexed by repeater page ID
*
* @param mixed|null Optionally specify key to retrieve just one
* @return array|InputfieldWrapper
*
*/
public function getWrappers($key = null) {
if(!is_null($key)) {
return isset($this->wrappers[$key]) ? $this->wrappers[$key] : null;
}
return $this->wrappers;
}
/**
* @return InputfieldWrapper
*
*/
public function ___getConfigInputfields() {
$inputfields = parent::___getConfigInputfields();
return $inputfields;
}
}