I haven't tested this for validity, but it should be something like:
$this->setDecorators(array(
'FormElements',
array('HtmlTag', array('tag' => 'dl')),
array('FormErrors', array(
'placement' => 'prepend',
'markupListStart' => '<div class="msg msg-error">',
'markupListEnd' => '</div>',
'markupListItemStart' => '<p>',
'markupListItemEnd' => '</p>',
)),
array('HtmlTag', array('tag' => 'div', 'class' => 'inner-form')),
array('Form', array('class' => 'basic'))
));
If that still isn't right, please post the code you've got so far and the
HTML output that you are getting.
Konr Ness
On Tue, Jan 19, 2010 at 11:57 AM, <[email protected]> wrote:
> I would like to get a similar form:
>
> <form enctype="multipart/form-data" method="post" action="" class="basic">
> <div class="inner-form">
> <div class="msg msg-error"><p>I'm an error message!</p></div>
> <dl>
> <dt><label for="some1">Username:</label></dt>
> <dd>
> <input type="text" name="some1" id="some1" class="txt"/>
> </dd>
>
> <dt><label for="some3">Password:</label></dt>
> <dd>
> <input type="text" name="some3" id="some3" class="txt"/>
> </dd>
>
> <dt></dt>
> <dd>
> <input type="submit" value="Log in" class="button"/>
> </dd>
> </dl>
> </div>
> </form>
>
>
> --------------------------------------------------------------------
> How do i get it with Decorators? I try with the following code but
> something still missing:
>
> 1. <div class="inner-form"> - that wraps all elements inside the form.
> 2. <div class="msg msg-error"><p>I'm an error message!</p></div> - error
> message.
> --------------------------------------------------------------------
>
> <?php
>
> class Core_Form_Utenti_Login extends Zend_Form {
>
> protected $_standardElementDecorator = array(
> 'ViewHelper',
> array('HtmlTag', array('tag' => 'dd')),
> 'Errors',
> array('Label', array('tag' => 'dt'))
> );
>
> protected $_buttonElementDecorator = array(
> 'ViewHelper',
> array('HtmlTag', array('tag' => 'dd')),
> 'Label'
> );
>
>
> public function init() {
>
> $username = new Zend_Form_Element_Text('username');
> $username->setFilters(array('StringTrim', 'StringToLower'))
> ->setLabel('Username:')
> ->setRequired(true)
> ->setDecorators($this->_standardElementDecorator)
> ->setAttrib('class', 'txt');
>
> $password = new Zend_Form_Element_Password('password');
> $password->setFilters(array('StringTrim'))
> ->setLabel('Password:')
> ->setRequired(true)
> ->setDecorators($this->_standardElementDecorator)
> ->setAttrib('class', 'txt');
>
> $submit = new Zend_Form_Element_Submit('accedi');
> $submit->setLabel('Accedi')
> ->setIgnore(true)
> ->setDecorators($this->_buttonElementDecorator)
> ->setAttrib('class', 'button');
>
> $this->addElements(array($username, $password, $submit));
>
> $this->setDecorators(array(
> 'FormElements',
> array('HtmlTag', array('tag' => 'dl')),
> array('Description', array('placement' => 'prepend',
> 'class' => 'error')),
> array('Form', array('class' => 'basic'))
> ));
> }
> }
>
>
>
>
>
>
>
>
>
>