2013-06-06 2 views
1

가 나는 젠드 양식이 있습니다Zend 보낸 사람 : 양식의 요소 하나만 표시하는 방법은 무엇입니까?

// Email 
    $email = $this->createElement('text', 'email'); 
    $email->setLabel('Адрес электронной почты:') 
     ->addValidator('EmailAddress') 
     ->addValidator('StringLength', FALSE, array(6, 30)) 
     ->setRequired(TRUE); 

    // Пароль 
    $password = $this->createElement('password', 'password'); 
    $password->setLabel('Пароль:') 
     ->addValidator('StringLength', FALSE, array(6, 30)) 
     ->setRequired(TRUE); 

    // Шрифт капчи 
    $fonts = scandir(APPLICATION_PATH . '/other/fonts/'); 
    $font = APPLICATION_PATH . '/other/fonts/' . $fonts[rand(2, sizeof($fonts) - 1)]; 

    // Инициализация капчи 
    $captcha = new Zend_Form_Element_Captcha(
     md5($_SERVER["REMOTE_ADDR"] . date('d.m.Y')), 
     array('label' => 'Введите код с картинки:', 
       'required' => TRUE, 
       'captcha' => array(
        'captcha' => 'Image', 
        'FontSize' => rand(25, 30), 
        'wordLen' => rand(4, 6), 
        'timeout' => 300, 
        'font'  => $font, 
        'imgDir' => 'img/captcha/', 
        'imgUrl' => '/img/captcha/', 
      ))); 

    $submit = $this->createElement('submit', 'submit_button', array(
                    'label' => 'Enter', 
                  )); 

을 그리고이 양식에 대한 내 자신의 HTML 코드를 가지고, 그것은보기 스크립트에 포함되어 있지만, captcha 요소는 동적입니다. captcha 요소 html 코드 만 표시 할 수있는 방법이 있습니까? 좋아요 :

<!-- my html code --> 
<?php $this->myForm->captcha; ?> 
<!-- my html code --> 

감사합니다.

답변

2

그래 당신은 당신이 그것을 작동하게하는보기 스크립트에 양식을 전달해야

아래처럼 사용할 수 있습니다. 보기 스크립트

public function someAction() 
{ 
    $this->view->form = new Form_Name(); // form class name 
} 

당신은 내가 더 당신을 도울 수 있다면 알려

<table> 
<tr> 
    <td><?= $this->form->getElement('captcha'); ?></td> 
</tr> 

</table> 

를 통해 요소를받을 수 있습니다.

+0

다행입니다. @ 로마 나자킨 – liyakat