这是我的代码我想为输入字段添加模板,这不是我想要的:
<?=$form->field($modelSignupSlotDates, 'SlotDate',
[
'template' => "<div class='col-md-2'><div class='form-group date'>{input}</div></div>",'options'=>['class'=>'form-group']
])->widget(DatePicker::classname(), [
'name'=>"SignupSlotDates[SlotDate]",
'options' => ['placeholder' => Yii::t($messageFile,'SignupExpirationDatePlaceholderText'), 'autocomplete' => 'off'],
'type' => DatePicker::TYPE_COMPONENT_APPEND,
'removeButton' => false,
'pluginOptions' => [
'autoclose'=>true,
'format' => 'mm-dd-yyyy',
'startDate' => date('m-d-Y'),
'endDate' => date('m-d-Y', strtotime('+60 days')),
]
])->label(false);?>
以下是我得到的HTML:
<div class="form-group field-signupslotdates-slotdate">
<div class="col-md-2">
<div class="form-group date">
<div id="signupslotdates-slotdate-kvdate" class="input-group date">
<input id="signupslotdates-slotdate" class="krajee-datepicker form-control" name="SignupSlotDates[SlotDate]" placeholder="Expiration date" autocomplete="off" data-datepicker-source="signupslotdates-slotdate-kvdate" data-datepicker-type="3" data-krajee-kvdatepicker="kvDatepicker_26ee0803" type="text">
<span class="input-group-addon kv-date-calendar" title="Select date">
<i class="glyphicon glyphicon-calendar"></i>
</span>
</div>
</div>
但我想要下面的结构,我无法做到。
<div class='col-md-2'><div class='form-group date'>
<input class="krajee-datepicker form-control" name="" placeholder="Date" type="text">
<span class='input-group-addon kv-date-calendar' title='Select date'><i class='glyphicon glyphicon-calendar'></i></span>
</div>
</div>