Alan Wagstaff
2008-02-20 12:18:01 UTC
Hi all,
I have added a "Remember me" checkbox to my login form and am having
troubles getting the label and checkbox to appear on the same line.
Specificly, I'm trying to get the checkbox to appear before the label.
Here's a screenshot of what it currently looks like:
Loading Image...
And here is the relavant bits of code for my checkbox element:
------------------------------------
// Remember me Checkbox
$elements['remember_me'] = new Zend_Form_Element_Checkbox('remember_me');
$elements['remember_me']->setRequired(false);
$elements['remember_me']->setLabel('Remember Me');
$elements['remember_me']->setDescription('(Not recommended for public
computers)');
$elements['remember_me']->setAttrib('checked', false);
// Add the elements to the form
$loginForm->addElement($elements['remember_me']);
// Form decorators
$loginForm->setDecorators(array(
array('FormElements', array('separator' => '<br/>')),
array('HtmlTag', array('tag' => 'div', 'class' => 'form')),
'Form')
);
// Element decorators
$loginForm->setElementDecorators(array(
'ViewHelper',
array('Description', array('tag' => 'div', 'placement' => 'PREPEND')),
'Errors',
'HtmlTag',
array('Label', array('tag' => 'strong', 'class' => 'form_element_label')),
));
// Custom element decorators
$loginForm->remember_me->addDecorator('Description', array('tag' =>
'div', 'placement' => 'APPEND'));
------------------------------------
And finally, here is the HTML that it produces for the checkbox element:
------------------------------------
<strong><label for="remember_me" class="form_element_label
optional">Remember Me</label></strong>
<div>
<input type="checkbox" name="remember_me" id="remember_me" value="" />
<div class="hint">
(Not recommended for public computers)
</div>
</div>
------------------------------------
I have tried removing my custom form / element decorators and using a
few examples previously posted here on the mailing list but all I can
manage is to get the label to appear below the checkbox rather than on
the same line.
Hoping a decorator expert can help :)
Thanks,
Al
I have added a "Remember me" checkbox to my login form and am having
troubles getting the label and checkbox to appear on the same line.
Specificly, I'm trying to get the checkbox to appear before the label.
Here's a screenshot of what it currently looks like:
Loading Image...
And here is the relavant bits of code for my checkbox element:
------------------------------------
// Remember me Checkbox
$elements['remember_me'] = new Zend_Form_Element_Checkbox('remember_me');
$elements['remember_me']->setRequired(false);
$elements['remember_me']->setLabel('Remember Me');
$elements['remember_me']->setDescription('(Not recommended for public
computers)');
$elements['remember_me']->setAttrib('checked', false);
// Add the elements to the form
$loginForm->addElement($elements['remember_me']);
// Form decorators
$loginForm->setDecorators(array(
array('FormElements', array('separator' => '<br/>')),
array('HtmlTag', array('tag' => 'div', 'class' => 'form')),
'Form')
);
// Element decorators
$loginForm->setElementDecorators(array(
'ViewHelper',
array('Description', array('tag' => 'div', 'placement' => 'PREPEND')),
'Errors',
'HtmlTag',
array('Label', array('tag' => 'strong', 'class' => 'form_element_label')),
));
// Custom element decorators
$loginForm->remember_me->addDecorator('Description', array('tag' =>
'div', 'placement' => 'APPEND'));
------------------------------------
And finally, here is the HTML that it produces for the checkbox element:
------------------------------------
<strong><label for="remember_me" class="form_element_label
optional">Remember Me</label></strong>
<div>
<input type="checkbox" name="remember_me" id="remember_me" value="" />
<div class="hint">
(Not recommended for public computers)
</div>
</div>
------------------------------------
I have tried removing my custom form / element decorators and using a
few examples previously posted here on the mailing list but all I can
manage is to get the label to appear below the checkbox rather than on
the same line.
Hoping a decorator expert can help :)
Thanks,
Al