젠드 폼을 만들었습니다. 몇 가지 요소를 추가했습니다. 모든 요소에 validate 특성을 넣었지만 유효성 검사는 유효하지 않습니다. 여기 내도 코드젠드 폼 유효성 검사가 작동하지 않습니다.
/* Form Elements & Other Definitions Here ... */
$this->setMethod('post');
$this->addElement('text', 'email', array(
'required' => true,
'filters' => array('StringTrim'),
'validators' => array(
'EmailAddress',
)
));
// Add the comment element
$this->addElement('textarea', 'comment', array(
// 'label' => 'Please Comment:',
'required' => true,
'validators' => array(
array('validator' => 'StringLength', 'options' => array(0, 20))
)
));
// Add a captcha
$this->addElement('captcha', 'captcha', array(
//'label' => 'Please enter the 5 letters displayed below:',
'required' => true,
'captcha' => array(
'captcha' => 'Figlet',
'wordLen' => 5,
'timeout' => 300
)
));
// Add the submit button
$this->addElement('submit', 'submit', array(
'ignore' => true,
'label' => 'Sign Guestbook',
));
// And finally add some CSRF protection
$this->addElement('hash', 'csrf', array(
'ignore' => true,
));
하지 운동에서 하나의 검증이다. 내보기에서 나는 단지 echo
양식 개체입니다. 어떤 시체가 내가 틀렸는가를 말해 줄 수 있습니까?
그냥 ... 당신의 코드에서'$ form-> isValid()'를 호출하고 있습니까? – dinopmi
@dinopmi'$ form-> isValid'는 서버 측 유효성 검사에 사용되지 않습니까? 확인은 위의 유효성 검사 코드가 서버 측 유효성 검사 또는 클라이언트 측 유효성 검사에 사용됨을 말해줍니다. –
nevermind, 나는 단지 dinopmi가 아래 답변에서 말한 것을 반복합니다 ... – jhuet