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've moved the forum!

Please use forum.silverstripe.org for any new questions (announcement).
The forum archive will stick around, but will be read only.

You can also use our Slack channel or StackOverflow to ask for help.
Check out our community overview for more options to contribute.

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   2850 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