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.

Customising the CMS /

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

SS3:Extend Group


Go to End


13 Posts   4609 Views

Avatar
Reflektera

49 Posts

7 September 2012 at 10:06pm

Hi all,

In 2.4 I've extended the built-in class Group and now I'm trying to port this to 3.0, but can't get it to work.

Organisation.php looks like this:
<?php
class Organisation extends DataExtension {
...
}

Organisations.php looks like this:
<?php
class Organisations extends ModelAdmin {
public static $managed_models = array(
'Group'
);
static $url_segment = 'abc';
static $menu_title = 'abc';
}

In _config.php I have this:
Object::add_extension('Group', 'Organisation');

Everything looks fine, besides the fact that I can't save a group through this modeladmin. All I get is this error message:

"ERROR [User Error]: singleton() Called without a class
IN POST /mokss/admin/organisations/Group/EditForm/field/Group/item/4/ItemEditForm
Line 372 in /Applications/MAMP/htdocs/*****/framework/core/Core.php"

Any clue?

Avatar
Willr

Forum Moderator, 5523 Posts

8 September 2012 at 4:46pm

You'll probably need to post the code to Organization. If you remove all the code from organization then try and save does it work?

Avatar
Reflektera

49 Posts

8 September 2012 at 5:32pm

Edited: 08/09/2012 5:33pm

Thanks for the reply but no, thats the thing, it won't save, even if it's empty.

Avatar
copernican

Community Member, 189 Posts

12 September 2012 at 4:03am

Reflektera, I basically recreated what you did on a fresh SS3.0 install. I was able to add a group and save no problem... Are there any other extensions or classes that could be causing the issue? Here is my code..

<?php 

class GroupModelAdmin extends ModelAdmin {
    
    public static $managed_models=array(
            'Group'
    );
    
    
    public static $url_segment='groupManager';
    public static $menu_title='Group Manager';
    
    
    
}

?>

<?php 

class GroupExtension extends DataExtension {
    
}

?>

and in my _config.php

Object::add_extension('Group', 'GroupExtension');

Did you make sure to ?flush=all as well after adding your extension?

Avatar
Reflektera

49 Posts

13 September 2012 at 12:23am

First of all, thanks for trying to help!

I made a fresh installation on my production server, I only tried on my local MAMP before. Copy pasted your code and ?dev/build?flush=all. All I got is a white screen, and I can't se anything special in the log files.

Group Manager appears in CMS though, but still the same error message... I tried it on 3.0.1, guess next step is trying it on 3.0.

Avatar
copernican

Community Member, 189 Posts

13 September 2012 at 12:30am

If memory serves, the white screen is normal though on a dev/build in 3.0 when in live mode.... but still getting the singleton error when saving. Very strange... Please let me know if you have luck in a 3.0 install.

Avatar
Reflektera

49 Posts

13 September 2012 at 1:05am

It works in 3.0, so something like a bug in the latest version. Guess I'll continue with 3.0 til I can figure out what is wrong with .0.1.

Didn't know about the white screen in live mode. Have to check it out, cause I think I had the site in dev mode...

Thanks again!

Avatar
copernican

Community Member, 189 Posts

14 September 2012 at 12:13am

I tested myself in a fresh 3.0.1 install, and worked okay for me. Maybe something you did in the previous install was causing issues? I would recommend re-downloading 3.0.1 and trying again but with 3.0.2 potentially not that far off, could just wait till that drops and update your 3.0 install.

Go to Top