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?