parent
4cdbf2a051
commit
6774920003
|
|
@ -31,6 +31,11 @@ class Repeater extends FormWidgetBase
|
|||
*/
|
||||
public $sortable = false;
|
||||
|
||||
/**
|
||||
* @var string Field name to use for the title of collapsed items
|
||||
*/
|
||||
public $titleFrom = false;
|
||||
|
||||
/**
|
||||
* @var int Maximum repeated items allowable.
|
||||
*/
|
||||
|
|
@ -88,6 +93,7 @@ class Repeater extends FormWidgetBase
|
|||
'form',
|
||||
'prompt',
|
||||
'sortable',
|
||||
'titleFrom',
|
||||
'maxItems',
|
||||
]);
|
||||
|
||||
|
|
@ -125,7 +131,7 @@ class Repeater extends FormWidgetBase
|
|||
if (!self::$onAddItemCalled) {
|
||||
$this->processExistingItems();
|
||||
}
|
||||
|
||||
|
||||
if ($this->previewMode) {
|
||||
foreach ($this->formWidgets as $widget) {
|
||||
$widget->previewMode = true;
|
||||
|
|
@ -137,6 +143,7 @@ class Repeater extends FormWidgetBase
|
|||
|
||||
$this->vars['prompt'] = $this->prompt;
|
||||
$this->vars['formWidgets'] = $this->formWidgets;
|
||||
$this->vars['titleFrom'] = $this->titleFrom;
|
||||
$this->vars['maxItems'] = $this->maxItems;
|
||||
|
||||
$this->vars['useGroups'] = $this->useGroups;
|
||||
|
|
|
|||
|
|
@ -181,7 +181,7 @@
|
|||
}
|
||||
|
||||
if (this.options.titleFrom) {
|
||||
$target = $('[data-field-name="'+this.options.titleFrom+'"]')
|
||||
$target = $('[data-field-name="'+this.options.titleFrom+'"]', $item)
|
||||
if (!$target.length) {
|
||||
$target = $item
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
<div class="field-repeater"
|
||||
data-control="fieldrepeater"
|
||||
<?= $titleFrom ? 'data-title-from="'.$titleFrom.'"' : '' ?>
|
||||
<?= $maxItems ? 'data-max-items="'.$maxItems.'"' : '' ?>
|
||||
data-sortable-container="#<?= $this->getId('items') ?>"
|
||||
data-sortable-handle=".<?= $this->getId('items') ?>-handle">
|
||||
|
|
|
|||
Loading…
Reference in New Issue