PHP PEAR Quickform 验证帮助
我正在使用 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。
有什么想法为什么这不起作用吗?
I am using PEAR's Quickform package to validate a form I have, I need help getting a validation rule applied to a group of checkboxes.
$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');
As it is now, the form does not show any errors when no checkboxes are checked. From what I have read in the documentation, you are supposed to use addRule when you want a validation rule applied to a whole group of elements.
Any ideas why this is not working?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
检查这个网站:
链接文本
并且不要忘记添加验证
check this site:
link text
and don't forget to add the validation