Jump to:

5450 Posts in 1672 Topics by 1197 members

Customising the CMS

SilverStripe Forums » Customising the CMS » SS3:Extend Group

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

Page: 1 2
Go to End
Author Topic: 1190 Views
  • Reflektera
    Avatar
    49 Posts

    SS3:Extend Group Link to this post

    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?

  • Willr
    Avatar
    Forum Moderator
    5462 Posts

    Re: SS3:Extend Group Link to this post

    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?

  • Reflektera
    Avatar
    49 Posts

    Re: SS3:Extend Group Link to this post

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

  • IOTI
    Avatar
    Community Member
    187 Posts

    Re: SS3:Extend Group Link to this post

    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?

  • Reflektera
    Avatar
    49 Posts

    Re: SS3:Extend Group Link to this post

    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.

  • IOTI
    Avatar
    Community Member
    187 Posts

    Re: SS3:Extend Group Link to this post

    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.

  • Reflektera
    Avatar
    49 Posts

    Re: SS3:Extend Group Link to this post

    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!

  • IOTI
    Avatar
    Community Member
    187 Posts

    Re: SS3:Extend Group Link to this post

    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.

    1190 Views
Page: 1 2
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.