Remember me? forgot password | register

SilverStripe Forum

4683 Posts in 1048 Topics by 664 members

Jump to:

Extending and hacking

If this is your first visit, you will need to register before you can post. However, you can browse all messages below.

Community » SilverStripe Forum » Extending and hacking » Option to leave out javascript validation
Page: 1 go to end Reply
Author Topic: Option to leave out javascript validation 1704 views
  • dio5
    avatar
    Community Member
    401 posts
    8 SilverStripe Sites

    Option to leave out javascript validation Link to this post

    Currently there doesn't seem to be a way to leave out javascript validation without hacking into the validator.php file, not a problem for me but not so good for upgrading.

    Doing on Requirements::clear(..) doesn't help, as the js will always be included when using 'new requiredfield'.

  • Ingo
    avatar
    Core Development Team
    379 posts

    Re: Option to leave out javascript validation Link to this post

    the trick is to clear requirements as close to rendering as possible:
    in your case of form-validation, this would be YourCustomFormClass->forTemplate()

    but you're right, there should be a switch to disable client-side validation...

  • Blackdog
    Blackdog's avatar
    Community Member
    136 posts

    Re: Option to leave out javascript validation Link to this post

    dio5, did you sort this out and get Requirements::clear() to work correctly?

  • Sam
    avatar
    Core Development Team
    482 posts

    Re: Option to leave out javascript validation Link to this post

    Perhaps we should add a couple of useXXValidation() methods on the form, to turn this on / off?


    $form->useJavascriptValidation(false);
    $form->usePHPValidation(false);

    If we did that, the best thing would be to have a FormField::includeJavascriptValidation() method that was called on each Field as part of the form rendering, if javascript validation was selected. It would be a bit of a refactoring, but it would put the responsibility for deciding whether to include javascript validation in the hands of the Form object, which is more appropriate than in the individual form fields.

    If we can make a patch for this on trunk, then Dio5 / Blackdog can apply it to their own branches before the next release.

    Last edited: 15 May 2008 at 3:39pm

  • Blackdog
    Blackdog's avatar
    Community Member
    136 posts

    Re: Option to leave out javascript validation Link to this post

    Dio5, I never could get the clear() to work even if I targeted the individual files.

  • dio5
    avatar
    Community Member
    401 posts
    8 SilverStripe Sites

    Re: Option to leave out javascript validation Link to this post

    Sam, that sounds like a good idea.

    I managed to work around this with subclassing RequiredFields and returning empty javascriptvalidation functions. - i e overriding those functions in Validator that make the js validation with a blank method.

  • Hamish
    avatar
    Community Member
    129 posts
    1 SilverStripe Site 1 SilverStripe Theme

    Re: Option to leave out javascript validation Link to this post

    W/regards Sam's comment, I'd be particularly interested in the ability to override any SS generated javascript with my own.

    For example, I use jQuery, so it totally sucks to have prototype imported and used to validate forms when there is an excellent jQuery Validitor plugin that is very easy to template and would add very little overhead to my existing pages. If the hooks were available, devs could produce jQuery/Mootools/YUI ports to perform these common tasks.

    If someone is already doing this, or there is a workable solution already, please let me know. Otherwise I'm interesting in helping produce such a framework if someone wants to point me in the right direction.

    Cheers!

    1704 views
go to top Reply

Currently Online:

Berteh, Invader_Zim, Craig, Nivanka

Welcome to our latest member: lorem