my AdminForm in the moudle src/model like
- Code: Select all
<?php
namespace Admin\Form;
use Zend\Form\Form;
use Zend\Captcha\AdapterInterface as CaptchaAdapter;
use Zend\Validator\ValidatorInterface;
use Zend\Captcha\Image;
use Zend\Form\Element;
class AdminForm extends Form
{
protected $captcha;
public function __construct()
{
parent::__construct('admin');
$ths->captcha = new Image(array(
'Expiration' => '300',
'wordlen' => '5',
'Height' => '50',
'Width' => '200',
'Font' => 'data/fonts/arial.ttf',
'FontSize' => '24',
'ImgDir' => 'data/images'
));
$this->setAttribute('method', 'post');
$this->add(array(
'name' => 'account',
'attributes' => array(
'type' => 'text'
),
'options' => array(
'label' => 'Account'
)
));
$this->add(array(
'name' => 'passwd',
'attributes' => array(
'type' => 'password'
),
'options' => array(
'label' => 'Passwd'
)
));
$this->add(array(
'name' => 'captcha',
'attributes' => array(
'type' => 'captcha'
),
'options' => array(
'label' => 'Please verify you are human.',
'captcha' => $this->captcha
)
));
$this->add(new Element\Csrf('security'));
$this->add(array(
'name' => 'submit',
'attributes' => array(
'type' => 'submit',
'value' => 'Submit'
)
));
}
}
my related view as
- Code: Select all
<div class="login">
<?php
$this->headTitle('Admin Homepage');
$form = $this->form;
$form->setAttribute('action', $this->url('admin', array('module' => 'admin','controller' => 'index','action' => 'dologin')));
$form->prepare();
echo $this->form()->openTag($form);
echo $this->formRow($form->get('account'));
echo $this->formRow($form->get('passwd'));
//echo $this->formCaptcha($form->get('captcha'));
echo $this->formElement($form->get('security'));
echo $this->formSubmit($form->get('submit'));
echo $this->form()->closeTag();
?>
</div>
line 16 start from
- Code: Select all
$ths->captcha = new Image(array(
'Expiration' => '300',
'wordlen' => '5',
'Height' => '50',
'Width' => '200',
'Font' => 'data/fonts/arial.ttf',
'FontSize' => '24',
'ImgDir' => 'data/images'
));

