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're retiring the forums!

The SilverStripe forums have passed their heyday. They'll stick around, but will be read only. We'd encourage you to get involved in the community via the following channels instead:

Customising the CMS /

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

Pass parameter to GridField to pre-populate new items

Go to End

2 Posts   915 Views


Community Member, 25 Posts

9 July 2014 at 10:02am

Edited: 09/07/2014 10:04am


I am using GridField on a custom form I've created in the front-end. The page I am serving gets a main record ID from the URL and the idea is to then show objects on the page with nice GridField editor.

The main object whose ID is passed via URL parameter has has_many relationship to items I am trying to create using the Gridfield.

This is what I got in terms of Form generation:
(there is extra layer of indirection as I've got booking requests linked to itineraries but that is not important for the example)

It works great in terms of listing all the elements if I manually specify the relation in the new item dialog, however, how do I automatically pre-fill that field? What happens is that the new element gets loaded on a new page, which loses the ID parameter, therefore I need to select the relation manually if I need it.

How can I dynamically define defaults for newly created GridField objects?

(I am using to facilitate the edits but it is just encapsulation over GF)


Community Member, 25 Posts

11 July 2014 at 1:37am

Nobody has ever encountered this?