trait HandleJsonRepeaters (View source)

Save repeaters in a json column instead of a new model.

This trait is not intended to replace main repeaters but to give a quick and easy alternative for simple elements where creating a new table might be an overkill.

Simply define an array with the repeater names on your repository: protected $jsonRepeaters = [ 'REPEATER_NAME_1', 'REPEATER_NAME_2', ... ]

Names must be the same as the ones you added in your repeaters attribute on config\twill.php or the actual filename for self-contained repeaters introduced in 2.1.

Supported: Input, WYSIWYG, textarea, browsers. Not supported: Medias, Files, repeaters.

Methods

array
prepareFieldsBeforeSaveHandleJsonRepeaters(Model|null $object, array $fields)

No description

array
getFormFieldsHandleJsonRepeaters(Model|null $object, array $fields)

No description

array
getJsonRepeater(array $fields, string $repeaterName, array $serializedData)

No description

Details

array prepareFieldsBeforeSaveHandleJsonRepeaters(Model|null $object, array $fields)

No description

Parameters

Model|null $object
array $fields

Return Value

array

array getFormFieldsHandleJsonRepeaters(Model|null $object, array $fields)

No description

Parameters

Model|null $object
array $fields

Return Value

array

array getJsonRepeater(array $fields, string $repeaterName, array $serializedData)

No description

Parameters

array $fields
string $repeaterName
array $serializedData

Return Value

array