Jump to:

5516 Posts in 1734 Topics by 1221 members

Customising the CMS

SilverStripe Forums » Customising the CMS » Custom popup for DataObject

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

Page: 1
Go to End
Author Topic: 1145 Views
  • Gusep
    Avatar
    Community Member
    2 Posts

    Custom popup for DataObject Link to this post

    Hi, I would appreciate any advise in this:

    I have a page which has a relation with two DataObjects

    class MobilePage extends Page {
    static $db = array(
    );
    static $has_many = array(
    'MyBrand' => 'MobileBrand',
    'MyModel' => 'MobileModel'
    );

    For each dataobject i have a separate tab in CMS with ComplexTableField in which I'm able to add/edit/remove new objects.

    Then it is more complicated, one of these dataobjects is related to another one:

    class MobileBrand extends DataObject {
    static $db = array(
    'BrandName' => 'Text'
    );

    static $has_many = array(
    'MyModel' => 'MobileModel'
    );

    So as you can see, the brand object can have many model objects.
    Now, in ComplexTableField for mobile brands I'm able to write out all the models that are related to this brand using custom getter. What I would like to achieve is, that each listed model name would be a link to the popup window where I can edit this model. I'm trying to use the link from the models ComplexTableField:

    $link = '<a href="admin/?executeForm=EditForm&flush=1&action_callfieldmethod&fieldName=MyModel&ctf[ID]='.$parent_id.'&ctf[childID]='.$model->ID.'&ctf[start]=0&methodName=show" target="_blank">'.$model->ModelName . "</a> ";

    Though this is not working as expected and everytime a click on any model I get the first one listed. If I try to use pagination and move forward and then backward I'm eventually able to find the model I wanted to edit. I'm apparently missing something here.

    Or is there any better way to achieve this functionality?

    Cheers..

  • UncleCheese
    Avatar
    4085 Posts

    Re: Custom popup for DataObject Link to this post

    Looks like the wrong link to me. Try

    /admin/EditForm/field/MyModel/item/$ID/edit

    I'll be pretty amazed if this gets working flawlessly. Please post your code if you do.

  • Gusep
    Avatar
    Community Member
    2 Posts

    Re: Custom popup for DataObject Link to this post

    Thanks for the reply UncleCheese, though this is not the way.. I got Disallowed action: 'EditForm' on controller 'CMSMain' error.

    1145 Views
Page: 1
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.