Quantcast
Channel:
Viewing all articles
Browse latest Browse all 4235

DataObject never calling init of its ContentController?

$
0
0

I was wondering as per general rule. If we look at the below code (v.3.1.3):

class MySymbol extends DataObject {
private static $db = array(
'Symbol' => 'Varchar(32)',
);
public function getCMSFields() {
Requirements::javascript('mysite/js/MySymbol_CMSEdit.js');
$fields = parent::getCMSFields();
$fields->addFieldToTab('Root.Main', new DropdownField('Symbol', 'Symbol', array(
'some' => 'data',
)));
return $fields;
}
}
class MySymbol_Controller extends ContentController {
public function init() {
parent::init();
Requirements::customScript('alert("hello")');
}
}

Should the init() be called when MySymbol instance is either being edited in admin or displayed on final page?

What I wanted to do was to attach custom javascript on admin side that reacts to DropdownField selection. This works fine when used in getCMSFields(), but doesn't seem to be ever called by the controller, which - I read - was the canonical place to use Requirements::

I even went further and added line: $this->httpError(500) - this did not fire either. So is the controller used at all?

Would anyone shed some light on me, please?


Posted to: DataObject never calling init of its ContentController? | Show Thread | Post Reply


Viewing all articles
Browse latest Browse all 4235

Trending Articles