CakePHP: $ form-> input ('checkbox');

with configuration div => false

$form->input('checkbox'); 

Print

 <input type="checkbox" value="1" ....> <label>checkbox</label> 

but i need a reverse order

 <label>checkbox</label> <input type="checkbox" value="1" ....> 

can it change?

+6
cakephp
source share
3 answers

There's an easier way to do this than the ShiVik method. This made you manually enter the title in the checkbox inside the tag. If you do not want this, there is a way to reorder the order of the elements.

In your example, you just want to reorder the $ format parameter, for example:

 <?php echo $this->Form->input('checkbox', array( 'type'=>'checkbox', 'format' => array('before', 'input', 'between', 'label', 'after', 'error' ) ) ); ?> 
  • Edit, just noticed that there was cake 1.2 in your message. This code is for cakes 1.3
+11
source share

You can do this by setting the label to false and using the "before" option to display the label where you want.

 <?php echo $form->input('checkbox', array( 'label'=>false, 'type'=>'checkbox', 'before' => '<label>checkbox</lablel>', 'div' => false )); ?> 

useful links

If this is not the case, you can use methods specific to the form element instead of the automatic form elements .

+2
source share

It is often easier to do something manually if the general wrapper of FormHelper::input does not match your score:

 echo $form->label('fieldname'); echo $form->checkbox('fieldname'); 

I often do not use FormHelper::input outside of the forests.

+1
source share

All Articles