我有一个包含以下小部件和验证器的表单:
$this->widgetSchema['num01'] = new sfWidgetFormChoice(array(
'choices' => Doctrine_Core::getTable('ticket')->getTicketnum(),
'expanded' => true, 'multiple' => true,
));
$this->validatorSchema['num01'] = new sfValidatorChoice(array(
'choices' =>
array_keys(Doctrine_Core::getTable('ticket')->getTicketnum()), 'required' => true, 'multiple' => true,
));
我遇到的问题是它显示了20个复选框,我想让它们只选择其中的5个。不多也不少。它必须正好检查5盒。如何自定义我的代码以使其以这种方式验证?感谢
答案 0 :(得分:0)
我试过这只是为了看看它是否会起作用。 :)
$this->validatorSchema['num01'] = new sfValidatorChoice(array(
'choices' =>
array_keys(Doctrine_Core::getTable('ticket')->getTicketnum()), 'required' => true,
'multiple' => true, 'max' => 5, 'min' => 5,
));