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

Javascript Validation on Module Forms in backend


Go to End


2102 Views

Avatar
Quadra

Community Member, 16 Posts

4 June 2009 at 10:42pm

Hi

I am writing a CRM module for a client and need to be able to validate the forms using javascript in the backend. Now I might have missed something fundamental, but it seems that there is no standard way to have this happen like there is in the frontend, i.e. it doesn't work out of the box.

Not a problem, so I have added some javascript, to my module (extension of leftandmain) and reloaded some Behaviour associated with Form_EditForm. This didn't work on its own as RequiredFields adds a bunch of Custom Javascript snippets and so do some of the form fields. These would normally get placed into the page when it is loaded as a whole. However as this is a form loaded by AJAX they are not.

Not a problem, I have extended my form loading action to pull out this custom Javascript and had my LeftAndMain javascript execute it and apply any behaviours etc.

The problem is that to achieve this I have had to modify the core class for Requirements as it is impossible (unless I am missing something) to extend this class as the $backend variable is private. Basically I need to add a function to just get the custom javascript out.

My question is - have I missed something obvious, is there an 'official way' to get this javascript out in an AJAX call and if not what are the chances of getting this class changed to either add a function to just return the custom javascript or modify the $backend variable to be protected instead of private?

It would be really nice if it was possible to decorate any class in the core...

Jason