Reputation: 93
I've googled and only found before after answer to get this done but that does not fit my problem. I want to move default label element outside of the div.
<?php echo $this->Form->input('name', array( 'before' => $this->Form->label('Subject:'), 'class' => 'form-control', 'div' => 'col-md-9 col-sm-9 col-xs-12')); ?>
Output is
<div class="col-md-9 col-sm-9 col-xs-12 required">
<label for="StaffSubject:">Subject:</label>
<input name="data[Staff][name]" class="form-control" maxlength="255" type="text" id="StaffName" required="required">
</div>
But I want this output instead
<label for="StaffSubject:">Subject:</label>
<div class="col-md-9 col-sm-9 col-xs-12 required">
<input name="data[Staff][name]" class="form-control" maxlength="255" type="text" id="StaffName" required="required">
</div>
Upvotes: 1
Views: 756
Reputation: 4469
This should work:
<?php echo $this->Form->input('name', array(
'label'=>'Subject',
'class' => 'form-control',
'wrapInput' => 'col-md-9 col-sm-9 col-xs-12',
)); ?>
Upvotes: 1
Reputation: 26
the best solution for that is to remove the label from your input and added before your input
<?php echo $this->Form->label('Subject:');
echo $this->Form->input('name', array(
'label' => false,
'class' => 'form-control',
'div' => 'col-md-9 col-sm-9 col-xs-12'
)); ?>
Upvotes: 1