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.

Archive /

Our old forums are still available as a read-only archive.

Moderators: martimiz, Sean, Ed, biapar, Willr, Ingo

required Fields within CheckableOption - CompositeField


Go to End
Reply


1736 Views

Avatar
zyko

Community Member, 66 Posts

8 August 2008 at 2:11am

Edited: 08/08/2008 2:13am

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