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

Include a custom field's javascript in a model admin instance


Reply

3 Posts   1689 Views

Avatar
AdamJ

30 June 2010 at 1:54am Community Member, 145 Posts

Hey guys,

I've possibly confused myself here, but I'd love some help.

I've created a couple custom form field types for a website, and these are being included both in a page type and in a model admin instance. It works just fine in the page type situation, but when it comes to the model admin, it doesn't include the javascript it requires. Is there a reason for this, or a step I'm missing?

Cheers in advance

Avatar
pascal20hh

29 September 2011 at 3:32am Community Member, 1 Post

Hey,

how can i add JavaScript to a custom Field in ModelAdmin / SilverStripe?

Avatar
Invader_Zim

29 September 2011 at 10:21am Community Member, 141 Posts

^^ try this:

class YourAdmin extends ModelAdmin {
...
public function init() {
parent::init();

Requirements::javascript('mysite/javascript/yourjavascript.js');
}
...
}

Cheers