Jeff Davidson
Jeff Davidson

Reputation: 1929

Checkbox inside of form label tag

I'm trying to figure out how I can put the checkbox inside the label tag like my template has it with the form helper with codeigniter.

echo "<div class=\"actions-left\" style=\"margin-top: 8px;\">";
echo form_label('Auto-login in future.', 'autologin');
echo form_checkbox('autologin');
echo "</div>";

Login Page

Login Template

Upvotes: 2

Views: 2869

Answers (3)

Murat &#220;nal
Murat &#220;nal

Reputation: 396

I do not know HTML, CSS standarts well but this seems a little bit wierd to me. I mean, "checkbox in a label"

I think you should solve this issue with css. Please, check this out http://alexking.org/blog/2005/07/18/css-checkbox-label-positioning

Perhaps, i may be wrong here so i do not want to push my idea too much.

Best Regards

Upvotes: 1

Damien Pirsy
Damien Pirsy

Reputation: 25445

I don't have time to check now, but is it valid markup? anyway, you can use the "regular" html for the <label> tag:

<div class="actions-left" style="margin-top: 8px">
<label for="autologin">Auto-login in future <?php echo form_checkbox('autologin'); ?>
</label>
</div>

Or you could try using the return value of form_checkbox() as the 1st argument of form_label(), i.e. it's content:

echo "<div class=\"actions-left\" style=\"margin-top: 8px;\">";
echo form_label(form_checkbox('autologin'), 'autologin');
echo "</div>";

Upvotes: 1

Brian
Brian

Reputation: 15706

Well I don't know CodeIgniter, but would this work:

echo form_label( form_checkbox( 'autologin' ) . ' Auto-login in future' );

Upvotes: 8

Related Questions