Remember me? forgot password | register

SilverStripe Forum

4682 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 » required Fields within CheckableOption - CompositeField
Page: 1 go to end Reply
Author Topic: required Fields within CheckableOption - CompositeField 204 views
  • zyko
    avatar
    Community Member
    64 posts

    required Fields within CheckableOption - CompositeField Link to this post

    I've some side effects using required fields within this
    CheckableOption Field which is part of forum code.


    $fs->push(new CheckableOption("EmailPublic", new EmailField('Email','Email *',"")),false);
    $fs->push( new CheckableOption('CountryPublic',new TextField('Country','Country *'),true,true));
    $fs->push(new PasswordField("Password", "Passwort *"));
    ...
    $validator = new RequiredFields('Email','Password',...)

    if i send the form without javascript (hack-test) and don't fill out Email, there's no response
    under the field like 'you have to fill out Email' or so...
    if i leave out Password anything is' fine.
    same Problem with Country...

    And some strange things happen also if javascript is enabled in the client.
    the red error-text doesn't disappear sometimes, although there's entered text and the field was left by clicking in some other field.

    i know that CheckableOption is not part of the core of ss.
    But it feels to me, that there is something wrong with handling required fields...
    i can hack in code, if someone could give me a hint where to search for...

    fe: there's the code for


    class CheckableOption extends CompositeField {
       protected $childField, $checkbox;
          
       function __construct($checkName, $childField, $value = "", $readonly = false) {
          if( $readonly )
             $this->checkbox = new CheckboxFieldDisabled($checkName, "", $value);
          else
             $this->checkbox = new CheckboxField($checkName, "", $value);
                
          $this->childField = $childField;
          
          $this->children = new FieldSet(
             $this->childField,
             $this->checkbox
          );
       }
       
       function FieldHolder() {
          return FormField::FieldHolder();
       }
       
       function Title() {
          return $this->childField->Title();
       }
       
       function Field() {
          return $this->childField->Field() . ' ' . $this->checkbox->Field();
       }
    }

    no special thing done for required fields, so either the problem is deeper (CompositeElement)
    or there has to be something more done in CheckableOption

    Last edited: 8 August 2008 at 2:13am

    204 views
go to top Reply

Currently Online:

bebabeba, Invader_Zim, joon, Matt Hardwick

Welcome to our latest member: Boomer T