Jump to:

7938 Posts in 1541 Topics by 945 members

DataObjectManager Module

SilverStripe Forums » DataObjectManager Module » Validation in DataObjectManager_Popup

Discuss the DataObjectManager module, and the related ImageGallery module.

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

Page: 1
Go to End
Author Topic: 1062 Views
  • Mad_Clog
    Avatar
    Community Member
    78 Posts

    Validation in DataObjectManager_Popup Link to this post

    I need some custom validation in a popup, but in the code the validator get unset specifically.

    File: DataObjectManager.php
    Line: 792
    Code: $this->unsetValidator();

    Why is this??

  • UncleCheese
    Avatar
    4085 Posts

    Re: Validation in DataObjectManager_Popup Link to this post

    Javascript conflicts.. that validator brings in prototype and all sorts of junk. You can try enabling it again, but I've never had any luck with it. Much better to use jQuery based validation.

  • Mad_Clog
    Avatar
    Community Member
    78 Posts

    Re: Validation in DataObjectManager_Popup Link to this post

    Wouldn't it be better to just disable the javascript validation handler in that case?
    Then you could atleast still use server side validation

          $validator->setJavascriptValidationHandler('none');
          parent::__construct($controller, $name, $fields, $actions, $validator);
    //      $this->unsetValidator();

  • UncleCheese
    Avatar
    4085 Posts

    Re: Validation in DataObjectManager_Popup Link to this post

    Yup. That's some old code you're looking at.

  • Mad_Clog
    Avatar
    Community Member
    78 Posts

    Re: Validation in DataObjectManager_Popup Link to this post

    I'm using the latest version of DOM from the trunk.
    Are you going to include this in your next release?

  • Mad_Clog
    Avatar
    Community Member
    78 Posts

    Re: Validation in DataObjectManager_Popup Link to this post

    Here's an updated code snippet which i think should be included in the DOM

          // disable javascript validation to prevent JS errors
          if (!empty($validator) && $validator instanceof Validator) {
             $validator->setJavascriptValidationHandler('none');
          }
          parent::__construct($controller, $name, $fields, $actions, $validator);
    //      $this->unsetValidator();

  • Mad_Clog
    Avatar
    Community Member
    78 Posts

    Re: Validation in DataObjectManager_Popup Link to this post

    *bump*
    This still needs to be patched in

          parent::__construct($controller, $name, $fields, $actions, $validator);
          if ($this->validator instanceof Validator) {
             $this->validator->setJavascriptValidationHandler('none');
          } else {
             $this->unsetValidator();
          }

    1062 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.