我正在使用PEAR的Quickform包来验证我拥有的表单,我需要帮助将验证规则应用于一组复选框。
$subjectArea[] = HTML_QuickForm::createElement('advcheckbox', 'SubjectArea', null, 'Student', 'id="subjectareastudent"', 'Student');
$subjectArea[] = HTML_QuickForm::createElement('advcheckbox', 'SubjectArea', null, 'Course', 'id="subjectareacourse"', 'Course');
$subjectArea[] = HTML_QuickForm::createElement('advcheckbox', 'SubjectArea', null, 'Faculty', 'id="subjectareafaculty"', 'Faculty');
$subjectArea[] = HTML_QuickForm::createElement('advcheckbox', 'SubjectArea', null, 'Other', 'id="subjectareaother"', 'Other');
$form->addGroup($subjectArea, 'subjectArea', 'Subject Area:');
$form->addRule('SubjectArea', 'Please specify a subject area', 'required');与现在一样,如果未选中任何复选框,则表单不会显示任何错误。根据我在文档中读到的内容,当您想要将验证规则应用于整个元素组时,应该使用addRule。
你知道为什么这不起作用吗?
发布于 2009-09-15 01:25:24
查看此站点:link text
别忘了添加验证
if ($form->validate()) {
echo 'hello';
}https://stackoverflow.com/questions/1421986
复制相似问题