Jump to:

5542 Posts in 1739 Topics by 1225 members

Customising the CMS

SilverStripe Forums » Customising the CMS » Javascript Validation on Module Forms in backend

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

Page: 1
Go to End
Author Topic: 1532 Views
  • e-scape
    Avatar
    Community Member
    16 Posts

    Javascript Validation on Module Forms in backend Link to this post

    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

    1532 Views
Page: 1
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.