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.

Archive /

Our old forums are still available as a read-only archive.

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

ModelAdmin


Go to End


17 Posts   6146 Views

Avatar
UncleCheese

Forum Moderator, 4102 Posts

15 November 2008 at 6:25am

Okay, I love the idea, but I have no idea how to use it. I put this in my mysite/code/ folder:

<?php

class MyModelAdmin extends ModelAdmin
{
protected static $managed_models = array (
'StaffMember'
);

public function Link()
{
return 'admin/mymodeladmin/';
}
}

?>

Not noticing anything new in the CMS. Did I do this right?

Avatar
UncleCheese

Forum Moderator, 4102 Posts

18 November 2008 at 4:39am

Seriously? No one knows how to use this thing?

Avatar
jam13

121 Posts

18 November 2008 at 4:59am

There's precious little documentation on this that I can find. I've got as far as getting a new tab to appear in the admin panel, and it seems to have all the right controls, however clicking on "Create" just throws a js error:

processOnDemandHeaders is not defined

which seems to be jQuery related. I'm planning on debugging this further when I get the time, but I'd like to hear if anyone has actually got this to work.

Avatar
(deleted)

Community Member, 473 Posts

18 November 2008 at 7:45am

I have three working, and will be updating the docs shortly. Assuming that the code is in MyModelAdmin.php, have you tried adding ?flush=1?

jam13, that has been fixed in r65843 and r65851

Avatar
Fuzz10

Community Member, 791 Posts

18 November 2008 at 9:20pm

We can't get this thing going as well. It does display the interface (the left bar) , but nothing happens when you want to use it.

Love the idea though !

Avatar
jam13

121 Posts

18 November 2008 at 11:33pm

Try checking out the lastest 2.3 branch code (not nightly builds which apparently are not being updated). I finally got this working last night after being told by simon_w that there had been a number of fixes for modeladmin in the last few days.

http://svn.silverstripe.com/open/phpinstaller/branches/2.3/

Avatar
Fuzz10

Community Member, 791 Posts

19 November 2008 at 2:07am

Hi Jam,

Thanks for the tip, that helped !

Love what I'm seeing so far !

Avatar
UncleCheese

Forum Moderator, 4102 Posts

25 November 2008 at 8:24am

I have no idea how you guys are getting this to work. I don't see any new tab in the CMS, and when I try to manually enter the url /admin/crm, I get a Fatal Error: Disallowed action "crm" on controller CMSMain.

Here's my code:

<?php

class MyModelAdmin extends ModelAdmin
{
	protected static $managed_models = array (
		'StaffMember'
	);
	
	
	static $url_segment = 'crm';
	static $menu_title = 'My CRM';	
}
class StaffMember extends SortableDataObject
{
	static $db = array (
		'Name' => 'Varchar(50)',
		'Title' => 'Varchar(50)',
		'Description' => 'Text'
	);
	
	static $has_one = array (
		'Photo' => 'Image',
		'AboutPage' => 'AboutPage'
	);
	
	static $searchable_fields = array (
		'Name', 'Title'
	);
	
}

?>

Go to Top