如何更改ZF1验证码的html视图

时间:2015-02-28 08:10:45

标签: php zend-framework

我没有以zend形式使用验证码我直接在控制器上写入zend captch代码。我的代码是:

IndexController.php

public function loginAction(){


        $this->view->assign('action',"/sabkuch/index/auth");
        $this->view->assign('user','username');
        $this->view->assign('passwd','Password');
        //$a=$this->_helper->Comman->textEmail("hi........","htm body.......","pkr","from@gm.com","xyz","xyz@gm.com");
        //echo $a; die;
        // Our form object...  

// And here's our captcha object...  
$captcha = new Zend_Form_Element_Captcha('captcha',  
        array('label' => 'Write the chars to the field',  
        'captcha' => array( // Here comes the magic...  
        // First the type... 

        'captcha' => 'Image',
        'useNumbers'  => true,
         'fontSize' => '22',
        'wordLen' => '4',
        'height' => '57',
        'width' => '235',
        // Captcha timeout, 5 mins  
        'timeout' => 300,  
        // What font to use...  
        'font' => APPLICATION_PATH . '/../public/font/6.ttf',
        // Where to put the image  
        'imgDir' => APPLICATION_PATH . '/../public/captcha/',  
        // URL to the images  
        // This was bogus, here's how it should be... Sorry again :S  
        'imgUrl' => 'http://localhost/sabkuch/public/captcha/',  
))); 

        $this->view->captcha = $captcha;

     }

Login.phml

<table width="100%" border="0" cellspacing="0" cellpadding="1"> 
<form class="form_align" name="login" method="post" action="<?php echo $this->escape($this->action);?>"> 
<tbody> 
<tr> 
<td align="left"><strong><?php echo $this->escape($this->user);?></strong></td> 
</tr> 
<tr> 
<td align="left"><?php echo $this->formText('username', '', array(
                            'class' => 'textfield',
                            'alt'   => 'NOBLANK~loginEmail~DM~',
                            'size'  => '30',
                            ) 
                            ); ?>
</td> 
</tr> 
<tr> 
<td align="left"><strong><?php echo $this->escape($this->passwd);?></strong></td> 
</tr> 
<tr> 
<td align="left"><?php echo $this->formPassword('passwd', '', array(
                            'class' => 'textfield',
                            'alt'   => 'NOBLANK~loginEmail~DM~',
                            'size'  => '30',
                            ) 
                            ); ?>
</td> 
</tr> 
<tr> 
<td align="left"><strong>Set Captcha</strong></td> 
</tr>   


<tr> 
<td align="left"><?php                                                           
echo $this->captcha->render($this, null) ;
?>

</td></tr>
<tr> 
<td align="left" style="padding-top:5px">
<?php echo $this->formHidden('id', 'login'); ?>
    <input type="submit" name="submit" value="Submit">                  </td> 
    </tr> 
  </tbody> 
  </form>
</table>

captch代码输出

<dd id="captcha-element">
<img width="235" height="57" alt="" src="http://localhost/sabkuch/public/captcha/770eec95f4b247754b4b6c30cd74a4a4.png" />
<input type="hidden" name="captcha[id]" value="770eec95f4b247754b4b6c30cd74a4a4" id="captcha-id" />
<input type="text" name="captcha[input]" id="captcha-input" value="" /></dd>

我需要像我的要求那样的验证码html输出

 <tr><td> <dd id="captcha-element">
    <img width="235" height="57" alt="" src="http://localhost/sabkuch/public/captcha/770eec95f4b247754b4b6c30cd74a4a4.png" />
    <input type="hidden" name="captcha[id]" value="770eec95f4b247754b4b6c30cd74a4a4" id="captcha-id" />
</tr></td>

<tr><td>
    <input type="text" name="captcha[input]" id="captcha-input" value="" /></dd> 

</tr></td>

以zend形式我们添加decoratro但我直接在控制器上使用此验证码如何更改此输出的html

0 个答案:

没有答案