22850 Posts in 9874 Topics by 2803 members
General questions about getting started with SilverStripe that don't fit in any of the categories above.
|Go to End|
8 May 2013 at 12:12am
I have a page with a $has_many relationship to VideoSnippets. VideoSnippets class extends from DataObject and includes a $has_one relationship back to my page. It all works fine, but in the CMS when I go to my page, and click the big green button to add a VideoSnippet to the page I am on, the droplist for the page (relationship) is blank. I would expect this to be populated since it knows (shows in the bread crumbs) the page I clicked the Add on.
The droplist for the relationship is blank in the form, and hitting save will select the correct page. However is there a way I can have it already selected, or, even better, don't even show the relationship droplist?
8 May 2013 at 5:38am
You can easily remove the field by adding $fields->removeByName('PageID'); into the getCMSFields function of your DataObject.
I have been wondering why this field get's shown, but i guess it has to do with the fields be generated by the form scaffolidng.
The really weird part is that it will not allow you to actually change the relation to another page, if you try, it just sets the same page again.
Hope it helps
8 May 2013 at 8:12am
Perfect, that worked great thanks!.
I didn't think to do that, as I didn't think that method would exist/be called on the DataObject, I thought it came off page.
It would be even beter, if once it saved it redirected back to the gridview, instead of just reloading the page with green "Saved" message.
That wouldn't be a method on the DataObject, that would be something in the core to fix yea?
8 May 2013 at 6:19pm
There is an extension from UncleCheese that does exactly that (and a bit more)
I have only tried it on 3.1 but works there, however it returns you to the main tab of the page.
|Go to Top|