Re: optional rule quick_form
| From: | Uroš Gruber | Date: | Thu, 11 Aug 2005 13:06:56 +0000 |
| Subject: | Re: optional rule quick_form | ||
| References: | 1 2 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-220421@lists.php.net to get a copy of this message | ||
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.