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.

Customising the CMS /

Custom popup for DataObject


Reply


3 Posts   1225 Views

Avatar
Gusep

Community Member, 2 Posts

27 February 2009 at 4:22pm

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..

Avatar
UncleCheese

Forum Moderator, 4096 Posts

27 February 2009 at 5:37pm

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.

Avatar
Gusep

Community Member, 2 Posts

2 March 2009 at 9:41am

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