Welcome, Guest. Register Now!
   
Mark Forums Read Mark Forums Read Mark Forums Read


Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 06-04-2008, 03:30 PM
Junior Member
 
Join Date: Jun 2008
Posts: 1
Unhappy adding an id to a label tag

Hi everyone,

I'm creating a form and I just can't find how to give a <label> tag an id using zend_form. ->setAttrib('id', 'agreement-box') worked fine for the checkbox, but I couldn't do ->setAttrib('id', 'agreement-label') since the label is considered a decorator it seems. Here is what I want:

HTML Code:
<input class="checkbox" name="agreement-box" id="agreement-box" type="checkbox" />
<label id="agreement-label">I have read and agree to the <a href="#">Terms of Use</a> and <a href="#">Private Policy</a></label>
here is the zend_form code:

PHP Code:
        $agreementText $this->translate->_('I have read and agree to the');
        
$agreementText .= '<a href="#">' $this->translate->_(' Terms of Use') . '</a>';
        
$agreementText .= $this->translate->_(' and');
        
$agreementText .= ' <a href="#">' $this->translate->_('Private Policy') . '</a>';
        
$agreementBox $this->addElement('checkbox''agreement-box',
            array(
'label' => $agreementText));
        
$agreementBox $this->getElement('agreement-box')
                             ->
setAttrib('id''agreement-box')
                             ->
setRequired(true);
        
$agreementBox->setDecorators($decorators);
        
$label $agreementBox->getDecorator('label');  //set up label for separate styling
        
$label->setOption('placement''append'); 
as you can see i'm translating the label (to allow for multiple languages), which works fine but I also get a problem with the html tags getting converted.

here's zend's html output:

HTML Code:
<input type="checkbox" name="agreementbox" id="agreement-box" value="1">
<label for="agreement-box" class="required">I have read and agree to the&lt;a href=&quot;#&quot;&gt; Terms of Use&lt;/a&gt; and &lt;a href=&quot;#&quot;&gt;Private Policy&lt;/a&gt;:</label>
does anyone know how to fix this? I suppose that's 2 questions. I searched the forums and looked through the Zend manual, but I couldn't find anything about this level of form manipulation. Please help!
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT. The time now is 06:22 PM.