Reputation: 95
I want to create a form like this in Zend Framework :
<form action="some action" method="post">
<div class="login_form">
<h3>Admin Login</h3>
<ul>
<li class="login_user">
<input type="text" name="username" value="" />
</li>
<li class="login_pass">
<input type="password" name="password" value="" />
</li>
</ul>
</div>
<input type="submit" class="login_btn blue_lgel" name="submit" value="Login" />
</form>
How can i make it possible using zend_form class?? I am just new to the zend framework.
Upvotes: 0
Views: 3198
Reputation: 1692
Please, have a look at the documentation:
http://framework.zend.com/manual/1.12/en/zend.form.quickstart.html
That's what it's for: it's written to answer questions like yours.
Your code will look something like:
class MyForm extends Zend_Form
{
public function init()
{
$this->setAction('/myUrl')
->setMethod('post');
$this->addElement('text', 'username', array('required' => true));
$this->addElement('password', 'passw', array('required' => true));
}
}
Then in your controller's action:
public function myAction()
{
$this->view->myForm = new MyForm();
}
And in your view:
<?php echo $this->myForm; ?>
Upvotes: 2