我有 5 个文本表单
$number1 = new Text('number-1');
$number2 = new Text('number-2');
$number3 = new Text('number-3');
....
使用相关过滤器
foreach(...)
$input = new Input($elementName);
$validator = new ValidatorChain();
$validator->addByName('Int')
->addByName('Between', array(
'min'=>0,
'max'=>$this->maxAllowedTicket,
'inclusive'=>true));
$filter = new FilterChain();
$filter->attachByName('Int');
$input->setValidatorChain($validator);
$input->setFilterChain($filter);
我希望这 3 种形式中只有一种可以包含不同于 0 的值。然后有两个可能的错误。
太多的数字
$data['number1'] = 5;
$data['number2'] = 5;
$data['number3'] = 0;
$data['number4'] = 5;
$data['number5'] = 0;
没有号码
$data['number1'] = 0;
$data['number2'] = 0;
$data['number3'] = 0;
$data['number4'] = 0;
$data['number5'] = 0;
如何同时验证这多个字段?