Jump to:

5514 Posts in 1733 Topics by 1219 members

Customising the CMS

SilverStripe Forums » Customising the CMS » Adding unlimited repeating fields of the same type

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

Page: 1
Go to End
Author Topic: 1181 Views
  • DanStephenson
    Avatar
    Community Member
    115 Posts

    Adding unlimited repeating fields of the same type Link to this post

    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?

  • Ben Gribaudo
    Avatar
    Community Member
    181 Posts

    Re: Adding unlimited repeating fields of the same type Link to this post

    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

  • jadedstudio
    Avatar
    Community Member
    5 Posts

    Re: Adding unlimited repeating fields of the same type Link to this post

    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.

  • zenmonkey
    Avatar
    Community Member
    527 Posts

    Re: Adding unlimited repeating fields of the same type Link to this post

    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.

    1181 Views
Page: 1
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.