我用谷歌搜索过,只有在之后找到了才能完成这项任务,但这不适合我的问题。我想将默认标签元素移到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')); ?>
输出
<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>
但我想要这个输出
<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>
答案 0 :(得分:1)
最好的解决方案是从输入中删除标签并在输入之前添加
<?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'
)); ?>
答案 1 :(得分:1)
这应该有效:
<?php echo $this->Form->input('name', array(
'label'=>'Subject',
'class' => 'form-control',
'wrapInput' => 'col-md-9 col-sm-9 col-xs-12',
)); ?>