Setting a label's id in Zend_Form

Posted by slkandy on Stack Overflow See other posts from Stack Overflow or by slkandy
Published on 2009-03-26T16:56:43Z Indexed on 2010/05/07 15:38 UTC
Read the original article Hit count: 248

Filed under:
|
|
|

Hey, guys, I'm trying to set an id for one of my form's labels so I can hide it with jquery later. Here's my element:

$password = new Zend_Form_Element_Password('password');
$password->setLabel('Password:')
    ->setRequired(true)
    ->addFilter('StripTags')
    ->addFilter('StringTrim')
    ->addValidator('NotEmpty')
    ->setAttrib( "id", "password" );

In the source, it looks like this:

<dt>
<label for="password" class="required">Password:</label>
</dt>

<dd>
<input type="password" name="password" id="password" value="">
</dd>

I need the label to look like:

<label id="pass_label" for="password" class="required">Password:</label>

Any ideas?

© Stack Overflow or respective owner

Related posts about zend

Related posts about form