2009-09-14 86 views
1

我使用PEAR的Quickform包來驗證表單我有,我需要幫忙應用於一組複選框的驗證規則。PHP 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。

任何想法爲什麼這不起作用?

回答

1

檢查這個網站: link text

,不要忘記添加驗證

if ($form->validate()) { 
echo 'hello'; 
}