5416 Posts in 1652 Topics by 1188 members
|Go to End|
6 November 2010 at 8:41am
When adding a new entry using ModelAdmin I would like to have a dropdown list that fills out fields automatically on select.
I was thinking the best way to do this was to create a separate DataObject that holds all these "template" objects, and then use jQuery to loop through all the values on select and populate the relevant fields but not sure where to start, so if someone could point me in the right direction I would appreciate it. Ideally, I'd like to add a 'Save as default' button when creating a new record that would then create a new entry that would get added to the dropdown.
6 November 2010 at 9:19pm
create your dataobject for defaults
using getCMSFields add you new dropdown to select the defaults record on the target dataobject
use the jQuery to add on change of the new dropdown the reads the new records and writes them into the form
create an ajax function for the onchange to call that passes the selection and returns a JSON array of the required values
alternatively you could just add the new dropdown and then put all of the work into onbeforewrite - this could check the value of this one field and then depending on it's value populate everything else before the write
9 November 2010 at 8:02am
The jQuery approach is for sure the most proper but onBeforeWrite sounds like a much quicker fix, didn't think of that so cheers!
|Go to Top|