2012-06-05 3 views
1

다음 ZF 양식 요소가 있습니다.Zend_Form에 오류 메시지가 표시되지 않습니다.

$this->addElement('text', 'price', array(
     'required' => true, 
     'label'  => 'Price:', 
     'attribs' => array(
      'title'  => 'Please enter the value of your artwork'), 
     'filters' => array('Currency'), 
     'validators' => array(
      array('NotEmpty', true, array(
       'messages' => array(
        Zend_Validate_NotEmpty::IS_EMPTY => 
         "You must enter your artworks price"))), 
      array('Float', true, array(
       'messages' => array(
        Zend_Validate_Float::INVALID => 
         "You must enter a valid price", 
        Zend_Validate_Float::NOT_FLOAT => 
         "You must enter a valid price"))), 
      array('GreaterThan', true, array(
       'min' => 0.99, 
       'messages' => array(
        Zend_Validate_GreaterThan::NOT_GREATER => 
         "You must enter a value of £1.00 or more")))) 
    )); 

마지막으로 검증 오류 메시지가 설정되어있는 Zend_Validate_GreaterThan입니다, 내 문제는이 검증이 실패했을 경우의 오류 메시지가 폼에 표시되지 않는 것입니다. 렌더링 된 것은 모두 비어있는 순서가없는 목록입니다!

<ul> 
    <li></li> 
</ul> 

zend_form에서 출력 된 메시지를 확인하면 오류와 메시지가 표시됩니다.

array(1) { 
    ["price"]=> 
    array(1) { 
    ["notGreaterThan"]=> 
    string(39) "You must enter a value of £1.00 or more" 
    } 
} 

메시지가 양식에서 렌더링되지 않는 이유를 아는 사람이 있습니까? 사전에

많은 감사

게리

편집

내가 사용하고있는 유일한 장식은 내가 가지고있는 양식, 양식을 렌더링하는 viewscript이다.

$this->setDecorators(array(
    array('ViewScript', array('viewScript' => 'forms/add-item.phtml')) 
)); 

및 뷰 스크립트 자체. 요소의 형태 장식의 '에러'를 포함 잊

array(5) { 
    ["Zend_Form_Decorator_ViewHelper"]=> 
    object(Zend_Form_Decorator_ViewHelper)#157 (6) { 
    ["_buttonTypes":protected]=> 
    array(3) { 
     [0]=> 
     string(24) "Zend_Form_Element_Button" 
     [1]=> 
     string(23) "Zend_Form_Element_Reset" 
     [2]=> 
     string(24) "Zend_Form_Element_Submit" 
    } 
    ["_helper":protected]=> 
    NULL 
    ["_placement":protected]=> 
    string(6) "APPEND" 
    ["_element":protected]=> 
    NULL 
    ["_options":protected]=> 
    array(0) { 
    } 
    ["_separator":protected]=> 
    string(2) " 
" 
    } 
    ["Zend_Form_Decorator_Errors"]=> 
    object(Zend_Form_Decorator_Errors)#158 (4) { 
    ["_placement":protected]=> 
    string(6) "APPEND" 
    ["_element":protected]=> 
    NULL 
    ["_options":protected]=> 
    array(0) { 
    } 
    ["_separator":protected]=> 
    string(2) " 
" 
    } 
    ["Zend_Form_Decorator_Description"]=> 
    object(Zend_Form_Decorator_Description)#159 (6) { 
    ["_escape":protected]=> 
    NULL 
    ["_placement":protected]=> 
    string(6) "APPEND" 
    ["_tag":protected]=> 
    NULL 
    ["_element":protected]=> 
    NULL 
    ["_options":protected]=> 
    array(2) { 
     ["tag"]=> 
     string(1) "p" 
     ["class"]=> 
     string(11) "description" 
    } 
    ["_separator":protected]=> 
    string(2) " 
" 
    } 
    ["Zend_Form_Decorator_HtmlTag"]=> 
    object(Zend_Form_Decorator_HtmlTag)#160 (7) { 
    ["_encoding":protected]=> 
    NULL 
    ["_placement":protected]=> 
    NULL 
    ["_tag":protected]=> 
    NULL 
    ["_tagFilter":protected]=> 
    NULL 
    ["_element":protected]=> 
    NULL 
    ["_options":protected]=> 
    array(2) { 
     ["tag"]=> 
     string(2) "dd" 
     ["id"]=> 
     array(1) { 
     ["callback"]=> 
     array(2) { 
      [0]=> 
      string(22) "Zend_Form_Element_Text" 
      [1]=> 
      string(16) "resolveElementId" 
     } 
     } 
    } 
    ["_separator":protected]=> 
    string(2) " 
" 
    } 
    ["Zend_Form_Decorator_Label"]=> 
    object(Zend_Form_Decorator_Label)#161 (6) { 
    ["_placement":protected]=> 
    string(7) "PREPEND" 
    ["_tag":protected]=> 
    NULL 
    ["_tagClass":protected]=> 
    NULL 
    ["_element":protected]=> 
    NULL 
    ["_options":protected]=> 
    array(1) { 
     ["tag"]=> 
     string(2) "dt" 
    } 
    ["_separator":protected]=> 
    string(2) " 
" 
    } 
} 
+0

제공 한 양식 코드를 복사하여 테스트 양식에 추가 했으므로 가격이 올바르게 렌더링되었다는 오류 메시지를 볼 수있었습니다. 어떤 데코레이터가 그 요소에 사용되고 있으며, 특별한 것은 무엇입니까? – drew010

+0

안녕하세요, 귀하의 회신에 감사드립니다. 제가 사용하고있는 유일한 장식은 관람석입니다. 위의 편집을 참조하십시오. – Garry

+0

'Zend_Form_Element's에 추가 된 표준 요소 데코레이터는 무엇입니까? ViewScript 데코레이터를 사용하여 폼을 렌더링하는 것을 보았지만 각 요소는 자체 데코레이터 세트를 사용하여 렌더링합니다. 기회는 무엇이든간에'Errors' 데코레이터가없는 것입니다. 그들이 무엇인지보기 위해서'var_dump ($ this-> element-> price-> getDecorators()); '를 시도 할 수있다. – drew010

답변

1

이 때때로 발생을 다음

$attribFilterObj = new Freedom_Zend_Filter_HtmlAttribs(); 
$attribs = $attribFilterObj->filter($this->element->getAttribs()); 
?> 
<form <?php echo $attribs; ?>> 
<dl> 
    <?php echo $this->element->ArtworkTitle->title->render(); ?> 
    <?php echo $this->element->ArtworkDescription->description->render(); ?> 
    <?php echo $this->element->price->render(); ?> 
    <?php echo $this->element->Genres->render(); ?> 
    <?php echo $this->element->image->render(); ?> 
    <?php echo $this->element->add->render(); ?> 
</dl> 
</form> 

EDIT

위해서 var_dump의 출력이다. 커스텀 데코레이터를 사용한다면, 먼저 그것을 확인하십시오.

+0

안녕하세요, 귀하의 회신에 감사드립니다. 내가 사용하고있는 유일한 장식 자 위에 드루에게 언급 한 것처럼 관람석이 위의 편집을 참조하십시오. – Garry

0

를 인쇄 한 후 오류 메시지가 좋아 yourselve 얻을 필요가 생각을 확인, 나는 단지 ViewScript를 사용했다 당신은 그렇습니다. 이 그것을 해결 : 당신이 그 메시지를 수신 할 수 있도록하려면

($this is in the form class I created) 
$this->setDecorators(array(
     array('ViewScript', 
       array('viewScript' => '/formElementViewscripts/editRoughDraft/_form.phtml')), 
     'Form' 
    )); 

또한 양식에 기본 '양식'장식을 추가해야합니다. 코드를 살펴 보았지만 정확하게 이유를 정확히 알 수 없었습니다.

관련 문제