5450 Posts in 1672 Topics by 1197 members
|Go to End|
29 November 2012 at 12:17am
I have set up a class which:
# deals with 2 models : A and B, A has_many B, and B has_one A
# extends ModelAdmin
When I do a dev/buil, all things look good.
I have a gridfield for A, a Tab for B.
When I go in Pane B (page under Tab B) and when I click on "Add B" for adding a new object, then I have the good attributes of my B model
BUT beacuse of the has_one relationship that B has with A I get a DropDonwList in which SilverStripe gathers the A existing model with their ID displayed.
I would like to get the names of the A instances instead of the Id but I'm unaware how to achieve this.
One can't add a B object related to a A already existing object by selecting its Id number. Would be great to select the name of the A instance.
Do someone know how to achieve this ?
30 November 2012 at 2:18am
Add the drop down field manually and map the DataObject. Take alook at the DropdownField documentation for an example. http://api.silverstripe.org/3.0/forms/fields-basic/DropdownField.html
30 November 2012 at 5:08am Last edited: 30 November 2012 5:09am
Thanks to reply and help me.
I solved the problem by doing the way you described.
We have to map the Id of the records to the Name
And everything works great.
The deeper I go into SS, the more I think it is a great framework. Well Designed.
|Go to Top|