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've moved the forum!

Please use forum.silverstripe.org for any new questions (announcement).
The forum archive will stick around, but will be read only.

You can also use our Slack channel or StackOverflow to ask for help.
Check out our community overview for more options to contribute.

General Questions /

General questions about getting started with SilverStripe that don't fit in any of the categories above.

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

How to get Model Admin without Table , just to edit one Object !


Go to End


4 Posts   868 Views

Avatar
DesignerX.com.au

Community Member, 107 Posts

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 :D

Thanks

Avatar
swaiba

Forum Moderator, 1899 Posts

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.

Avatar
kinglozzer

Community Member, 187 Posts

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.

Good luck!

Avatar
DesignerX.com.au

Community Member, 107 Posts

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 :D