我设置了这个zend form element radio:
//nationality
$this->addElement('radio', 'nationality', array('label' => 'F_NATIONALITY', 'separator' => ' ', 'label_class' => 'l_radio', 'required' => true));
$this->nationality->addMultiOption('italian', 'F_NATIONALITY_IT');
$this->nationality->addMultiOption('foreign', 'F_NATIONALITY_FO');
$this->nationality->addValidator('NotEmpty');
这是输出:
你不明白的是,即使我设置了'required'验证器和'NotEmpty'属性,我也无法显示错误信息?
由于
答案 0 :(得分:0)
$nationality= new Zend_Form_Element_Radio('nationality');
$nationality->setLabel('Nationality:')
->setRequired(true)
->addMultiOptions(array(
'italian' => 'Italian',
'foreign' => 'Foreign'
))
->setSeparator(' ');
//->setDecorators(array('ViewHelper','Label', 'Errors', array('HtmlTag', array('tag' => 'p'))));
以上代码将创建国籍单选按钮,其中包含两个意大利语和外语选项。