Jump to:

7940 Posts in 1543 Topics by 946 members

DataObjectManager Module

SilverStripe Forums » DataObjectManager Module » Uncle Cheese? extending RequiredFields ConfirmedPasswordField issue

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: 553 Views
  • nimesodelta
    Avatar
    Community Member
    18 Posts

    Uncle Cheese? extending RequiredFields ConfirmedPasswordField issue Link to this post

    Hi all,

    Uncle Cheese! are you there? I'm using allot of code snippits from the Postale module as I really like all the ajax calls etc etc, great job!.

    Anyway I've successfully extended RequiredFields so I can use jQuery.form.js (lol... I think that's why). It is adding the xtra classes to the #Password div a-ok but that about all it does... the jQuery doesn't seem to append the required message label. The labels append fine on all the other required fields just not the confirmedPassword. Any help would be great! I'll buy you a beer!

    Code below:

    <?php

    class CompanyMemberValidator extends RequiredFields
    {
       protected static $jquery_included = false;
       
       protected static $field2class = array (
          'ConfirmedPasswordField' => 'password',
          etc etc etc....
       );
       
       protected static function get_class_for($fieldClass)
       {
          if(isset(self::$field2class[$fieldClass]))
             return self::$field2class[$fieldClass];
          return false;
       }
       
       public static function jquery_included()
       {
          self::$jquery_included = true;
       }
       
       public function includeJavascriptValidation()
       {

          if($this->required) {
             $fields = $this->form->Fields();
             foreach($this->required as $name) {
                $field = $fields->dataFieldByName($name);
                $field->addExtraClass("required");
                if($class = self::get_class_for($field->class))
                   $field->addExtraClass($class);
             }
          }
          $form = $this->form->FormName();
       }
       
       public function javascript() {return;   }
       
    }

  • swaiba
    Avatar
    Forum Moderator
    1792 Posts

    Re: Uncle Cheese? extending RequiredFields ConfirmedPasswordField issue Link to this post

    Hi nimesodelta (and others),

    Mainly I am moving things from "General questions" because often they are not about getting started with SilverStripe and they do fit elsewhere on the forum and as well as keeping spammers out I'd like to keep the information better organised in these forums.

    Also if you want to label you post for the attention of Uncle Cheese I'd recomened doing it in his section of the forum - but it is a little limiting as if you write your question in a good way you may find someone else can and will answer.

    I'll give you the choice of either UC's DOM section or All other modules... which would you like this to be moved to?

    Barry

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