[prev in list] [next in list] [prev in thread] [next in thread] 

List:       binarycloud-dev
Subject:    Re: [binarycloud-dev] validator in FormElement
From:       Jason Hines <jch () eyeintegrated ! com>
Date:       2004-03-12 23:28:12
Message-ID: 4052478C.9020506 () eyeintegrated ! com
[Download RAW message or body]

Sorry, but this seems bad for 2 reasons.  1. new class overhead 2. 
adding presentation / mark-up in PHP.

I think the better solution would be to add this behavior to 
FormComponent (formerly FormElement) and handled in the FormComponent 
template.

if ($this->children['input']->HasValidator('NotNullValidator')) {
	$this->SetTplVar('required',TRUE);
}

FormComponent.tpl

<td>
{if $required}<font color="red">*</font>{/if}
..

The above makes much more sense, but would require new 
HasValidator($name) method to FormInput.

My thinking here is that Form should be a full featured form system, 
capable of nearly all needs.  You should rarely have to extend Form 
unless its for doing something very obscure.


jason


Jean-Christophe Michel wrote:

> Le ven 12/03/2004 à 18:47, Daniel Bondurant a écrit :
> 
>>I would like to have a red star next to all fields in a form that are
>>required.  Is there any way to tell FormElement.tpl if a validator is
>>required for that element?
> 
> 
> RedStarFE extends FormElement
>    RedStarFE::Init() {
>       parent::Init();
>       
>       $role2id = $this->GetParam('role2id');       
>       if (count($this->children[$role2id['input']]->validators) > 0) {
>          $this->SetTplVar('redstar', '*');
>       }
>    }
> 
> Not so hard, but you need your own class.
> 
> You can change the condition to examine wether there's a
> NotVoidValidator, because just having a validator is not the proof that
> a value is mandatory.



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@binarycloud.tigris.org
For additional commands, e-mail: dev-help@binarycloud.tigris.org

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic