2009-05-05 8 views
4

젠드 기반 사이트에 필수 "이용 약관"체크 박스가있는 양식이 있습니다.체크 박스에 대한 사용자 정의 젠드 오류 메시지

"이용 약관에 동의해야합니다"라는 맞춤 메시지를 설정했습니다. 확인란을 "= '필요한'존재 '이기 때문에

그러나, 그것은 반환

젠드 프레임 워크에 정의 된이 일정
Field 'terms' is required by rule 'terms', but the field is missing 

:이 일정하게 편집 할 수

self::MISSING_MESSAGE  => "Field '%field%' is required by rule '%rule%', but the field is missing", 

는, 그러나 필요한 모든 체크 박스에 대한 오류보고가 변경됩니다.

이 특정 사례에 대한 오류보고에 어떻게 영향을 미칩니 까?

답변

3

이 같은 기본 메시지를 대체 할 수 있습니다 : 다음

$options = array(
       'missingMessage' => "Field '%field%' is required by rule '%rule%', dawg!" 
      ); 

를 실행 한 다음, 마지막으로

$input = new Zend_Filter_Input($filters, $validators, $myData); 

또는

$input = new Zend_Filter_Input($filters, $validators, $myData); 
$input->setOptions($options); 

...과 :

if ($input->hasInvalid() || $input->hasMissing()) { 
    $messages = $input->getMessages(); 
} 

Zend_Filter_Inputmanual 페이지에 언급되어 있습니다.

12

Zend_Form_Element_Checkbox을 사용하는 경우 customize the error messages on the Zend_Validate validators 수 있습니다.

$form->addElement('checkbox', 'terms', array(
    'label'=>'Terms and Services', 
    'uncheckedValue'=> '', 
    'checkedValue' => 'I Agree', 
    'validators' => array(
    // array($validator, $breakOnChainFailure, $options) 
    array('notEmpty', true, array(
     'messages' => array(
     'isEmpty'=>'You must agree to the terms' 
    ) 
    )) 
    ), 
    'required'=>true, 
); 

당신은 확인되지 않은 값이 "빈"이고 필드가

"필요"되었는지 확인하려면
관련 문제