我有5文本形式zf2驗證表單:如何驗證相關字段?
$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;
NO NUMBER
$data['number1'] = 0;
$data['number2'] = 0;
$data['number3'] = 0;
$data['number4'] = 0;
$data['number5'] = 0;
我如何可以驗證在同一時間這多個字段?
謝謝!它的工作原理,但我怎樣才能在ValidatorPluginManager中註冊這個翻譯器? – chrvadala
什麼翻譯? –
dunno,不使用它,但是你可以在輸入規範中傳遞完整的類名(字符串)作爲驗證器的名字 –