22855 Posts in 9971 Topics by 2805 members
General questions about getting started with SilverStripe that don't fit in any of the categories above.
|Go to End|
5 January 2013 at 1:40am
Hi, I am trying to create a ModelAdmin section that edits One Object instead of having a table of Objects .
If we look at the Settings Section/ModelAdmin then that is exactly what I want, When I click the Settings tab I get the textFields to edit the site Title & Tagline .
How can I do that ? been looking at the SiteConfig.php & CMSSettingsController.php for some time but didnt 100% get it all ..
Love to get some help & work out a solution that we can publish too
11 January 2013 at 11:28am
The easiest way of getting similar functionality I think would be to create the ModelAdmin with the DataObject.
Ensure the permissions of the DataObject make canCreate and canDelete return false.
Add a requireDefaultRecords function to ensure one record is always created on a dev/build (if it doesn't already exist).
The only downside is that you need to search for and then click the record to then edit it - however I know there is a small js hack to get records to auto load... it would take much to extend that to open the record into an edit form each time.
Not ideal GUI, but functionality - hope this helps.
11 January 2013 at 11:51pm
I've wondered how to do this before as well. I haven't had a chance to look at it properly, but from looking at the existing classes I'd guess:
CMSSettingsController extends LeftAndMain, not ModelAdmin, so when creating your class, try extending LeftAndMain and not ModelAdmin.
Then I think you'll need to overwrite getEditForm() to load in your DataObject - Use CMSSettingsController as an example.
It looks like there'll be extra stuff to work out, like getting the CMS actions to pass into the form, but it's a starting point.
13 January 2013 at 6:56pm
Hi, these sound like good solutions. I will be playing around with them soon .
If you guys have any related code, even 1/2 working please post here .
Thanks for your input guys
|Go to Top|