milesap Posted March 2, 2009 Share Posted March 2, 2009 Hello, I've been having a lot of trouble using Zend Form. The form validates just fine, but it's a real challenge to get it to display the form the way I'd like it to! I want to stay away from ViewScripts on this current project I'm working on. Here's what I want the form to display: <form name="login" method="post" action="http://www.example.com"> <fieldset> <legend>Step 1. Tell us about yourself</legend> <div class="field-group"> <label for="username">Username:</label> <input type="text" name="username" /> </div> <div class="field-group"> <label for="password">Password:</label> <input type="password" name="password" /> </div> </fieldset> <div class="form-button-group"> <input type="submit" id="signup-button" name="submit" value="Create Account" /> </div> </form> The above is a fairly simple login script. I've tried just about everything, including clearDecorators(), removeDecorator(), and creating a display group. I don't think I fully understand how to manipulate the Zend Forms. Here's my forms code: <?php class LoginForm extends Zend_Form { public function init() { $this->setAction('/index/form/') ->setMethod('post') ->setAttrib('id', 'loginForm'); $this->addElement('text', 'username', array('label' => 'Username')); $this->getElement('username') ->addValidator('alnum') ->setRequired(true) ->addFilter('StringTrim'); $this->addElement('password', 'password', array('label' => 'Password')); $this->getElement('password') ->addValidator('stringLength', TRUE, array(6)) ->setRequired(TRUE) ->addFilter('StringTrim'); $this->addElement('submit', 'Login'); $this->addDisplayGroup(array('username', 'password', 'Login'), 'loginForm'); //Not sure what to do here to get my form to display the correct output } } How would I be able to modify the decorators to give me the form layout shown above? Any help would be greatly appreciated Just incase this helps, the code above produces the following html: <form id="loginForm" enctype="application/x-www-form-urlencoded" action="/index/form/" method="post"><dl class="zend_form"> <dt> </dt><dd><fieldset id="fieldset-loginForm"><dl> <dt><label for="username" class="required">Username</label></dt> <dd> <input type="text" name="username" id="username" value="" /></dd> <dt><label for="password" class="required">Password</label></dt> <dd> <input type="password" name="password" id="password" value="" /></dd> <dt> </dt><dd> <input type="submit" name="Login" id="Login" value="Login" /></dd></dl></fieldset></dd></dl></form> Quote Link to comment https://forums.phpfreaks.com/topic/147493-help-with-zend-form/ Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.