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 /

Javascript Validation on Module Forms in backend


Reply


1570 Views

Avatar
e-scape

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