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   1724 Views

Avatar
AdamJ

Community Member, 145 Posts

30 June 2010 at 1:54am

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

Community Member, 1 Post

29 September 2011 at 3:32am

Hey,

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

Avatar
Invader_Zim

Community Member, 141 Posts

29 September 2011 at 10:21am

^^ try this:

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

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

Cheers