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.

We're retiring the forums!

The SilverStripe forums have passed their heyday. They'll stick around, but will be read only. We'd encourage you to get involved in the community via the following channels instead:

Customising the CMS /

Moderators: martimiz, Sean, Ed, biapar, Willr, Ingo, swaiba

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


Go to End


3 Posts   2510 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