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.

DataObjectManager Module

Discuss the DataObjectManager module, and the related ImageGallery module.

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

Uncle Cheese? extending RequiredFields ConfirmedPasswordField issue


Reply

2 Posts   568 Views

Avatar
nimesodelta

28 November 2011 at 11:31pm (Last edited: 4 December 2011 10:14pm), Community Member, 18 Posts

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;   }
   
}

Avatar
swaiba

28 November 2011 at 11:59pm (Last edited: 4 December 2011 10:14pm), Forum Moderator, 1796 Posts

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