Re: [PHP] optional rule quick_form

2005-08-11 Thread Torgny Bjers
Uroš Gruber wrote:

> Torgny Bjers said the following on 11.8.2005 14:44:
>
>> I am assuming that this is after a post operation. If it's JavaScript, I
>> think the question should be directed to another list. So, if you group
>> the elements that should be validated after the checkbox has been
>> checked, you can activate/deactivate the group validation rules based on
>> the state of the checkbox. Makes sense?
>
>
> If I understand your idea the code would look like this
> $form->addElement('text', 'taxNumber', 'Tax:');
> $checkbox = &HTML_QuickForm::createElement('checkbox', 'isCompany','');
>
> if ($checkbox->getChecked()) {
> $form->addRule('taxNumber','required','Tax number is required');
> }
>
> if ($form->validate()) {
> 


That would be the idea, yes. It was some time since worked with
Quick_Form, so there might be a specific order you need to perform the
adding of the rule in relation to the validate() method call on the
$form object.

> Btw yes it must be checked when user submit this. But If it's possible
> client option on rule, would be better.


I am not sure about this, is there even client-side validation support
in Quick_Form? Haven't really looked into this. I would suggest writing
a manual javascript evaluation for the specific fields that should be
visible when the checkbox is checked, or to have a postback between. The
JavaScript option sounds most tempting, since it makes it a bit more
user-friendly. That way you can use the JavaScript alert() function to
present the fields that have erroneous information as well as altering
styles in the fields in question to perhaps have a red border to
indicate errors.

Regards,
Torgny

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] optional rule quick_form

2005-08-11 Thread Uroš Gruber

Torgny Bjers said the following on 11.8.2005 14:44:

I am assuming that this is after a post operation. If it's JavaScript, I
think the question should be directed to another list. So, if you group
the elements that should be validated after the checkbox has been
checked, you can activate/deactivate the group validation rules based on
the state of the checkbox. Makes sense?


If I understand your idea the code would look like this
$form->addElement('text', 'taxNumber', 'Tax:');
$checkbox = &HTML_QuickForm::createElement('checkbox', 'isCompany','');

if ($checkbox->getChecked()) {
$form->addRule('taxNumber','required','Tax number is required');
}

if ($form->validate()) {


Btw yes it must be checked when user submit this. But If it's possible 
client option on rule, would be better.


regards



I have one checkbox. I checkbox is checked I show additional fields
(just set visiblity to true).  But some of that fields are required
only if this checkbox is checked. Is this possible with quick_form. I
try myself with grouping but without any luck.


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] optional rule quick_form

2005-08-11 Thread Torgny Bjers
I am assuming that this is after a post operation. If it's JavaScript, I
think the question should be directed to another list. So, if you group
the elements that should be validated after the checkbox has been
checked, you can activate/deactivate the group validation rules based on
the state of the checkbox. Makes sense?

Regards,
Torgny

Uroš Gruber wrote:

> Hi!
>
> I have one checkbox. I checkbox is checked I show additional fields
> (just set visiblity to true).  But some of that fields are required
> only if this checkbox is checked. Is this possible with quick_form. I
> try myself with grouping but without any luck.
>
> regards
>
> Uros
>

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] optional rule quick_form

2005-08-11 Thread Uroš Gruber

Hi!

I have one checkbox. I checkbox is checked I show additional fields 
(just set visiblity to true).  But some of that fields are required only 
if this checkbox is checked. Is this possible with quick_form. I try 
myself with grouping but without any luck.


regards

Uros

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php