I want add text filed as repeater like, if we add has_many for image .
We can add multiple, like that i need to add for input field.
please advice.
I want add text filed as repeater like, if we add has_many for image .
We can add multiple, like that i need to add for input field.
please advice.
To append multiple text fields, you will have to add a DataObject with
a Text
-field and connect it using has_many
on your class and has_one
on the new dataobject. Then add a GridField
to edit the connected Dataobjects.
If you want to get a more Asset-like editing experience, you can use the GridFieldEditableColumns
component from the symbiote/silverstripe-gridfieldextensions
If you mean you would like the fields to be dynamically added to the CMS without having to specify how many you want as a hard-coded value in the code, you may be interested in symbiote/silverstripe-multivaluefield
Definitely the more convenient solution.
To create a text field, you need to instantiate the TextField class, to the constructor of this class you can also pass a string value which will be the initial text of the text field.
Greetings,
Peter