开发者

Php Quickform Grouprule for Html-Select and Html-Input Group needed

i'm currently working on a big html form. I use Php Quickform to create and validate it. The form has a few Groups that consist of a Input-Textfield and a Select-field. The code for one of the groups

looks like this:

$autoren = array("0" => "", "1" => "Bob", "2" => "Harry", "3" => "Autor 3");
$arr[] = &HTML_QuickForm::createElement('text', 'autorT', 'AutorText', array('size' => 37, 'maxlength' => 50));
$arr[] = &HTML_QuickForm::createElement('select', 'autorO', 'AutorOptions', $aut开发者_运维知识库oren);
$form->addGroup($arr, 'Autoren', 'Autor:', '<br />');

I'm in desperate need of some kind of Rule/GroupRule that validates this group in the following way:

  1. If both fields are empty -> error.
  2. If one of the fields has a value in it, the other one must be empty, otherwise -> error.
  3. If both fields have values in them, they must match, otherwise -> error.

Can somebody explain to me how i can accomplish that? I already tried to write a custom rule, but somehow the code never called my validate method.


If you're using HTML_QuickForm2, then chaining the rules with _and() and _or() makes possible what you want. With QF1, it's not possible (except using a callback rule on the form).

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜