Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

We've moved the forum!

Please use forum.silverstripe.org for any new questions (announcement).
The forum archive will stick around, but will be read only.

You can also use our Slack channel or StackOverflow to ask for help.
Check out our community overview for more options to contribute.

Customising the CMS /

Moderators: martimiz, Sean, Ed, biapar, Willr, Ingo, swaiba

Adding unlimited repeating fields of the same type


Go to End


4 Posts   2564 Views

Avatar
DanStephenson

Community Member, 116 Posts

31 March 2009 at 7:01am

Edited: 31/03/2009 11:57am

Hi all,

I am looking to build a site, and for one of my templates, the user should be able to post an unlimited number of a certain content type, which in this case is links. For each link, I want the user to be able to add a title, and URL.

Instead of creating say 10 link fields for the client to populate in the CMS, I would like this to be flexible, so the client can have as many of these as they need. Is there a way in the CMS that I can make a "repeating field", so the client can add or remove the elements as needed? If so, can anyone tell me how to go about setting these up?

Avatar
Ben Gribaudo

Community Member, 181 Posts

1 April 2009 at 2:21am

Hi Dan,

Sounds like you need to build a link data type having fields URL and title. Then, from your page type, create a one-to-many relationship with the link data type. On your page type, you could use something like DataObjectManager in getCMSFields() to give you a way to create the link entries from the CMS admin interface.

Ben

Avatar
jadedstudio

Community Member, 5 Posts

7 November 2012 at 4:42am

Sorry to bump such an old thread but did you ever get this working?

I would like to do this in SilverStripe 3 but as yet haven't found a way.

I can generate extra form fields using jQuery, however it only saves the last field to the Database.

Any help would be really appreciated.

Avatar
zenmonkey

Community Member, 545 Posts

7 December 2012 at 2:33am

You need to add that field as its own data object and use a $has_many relation. Then you can use a grid field to manipulate it.