问题
I would like to add a class to all selects of an automagic created datepicker formgroup.
<?= $this->Form->input('hide', ['class'=>'classtoadd' ]); ?>
The result ist:
<div class="input date">
<label>Hide</label>
<select name="hide[year]">
<option value="" selected="selected"></option>
<option value="2020">2020</option>
...
</select>
<select name="hide[month]">
<option value="" selected="selected"></option>
<option value="01">Januar</option>
...
</select>
<select name="hide[day]">
<option value="" selected="selected"></option>
<option value="01">1</option><option value="02">2</option>
</select>
</div>
The class classtoadd
is simply missing from the selects. This workes perfectly on simple inputs. Is this an expected behaviour or am I doing something wrong?
Im using cakephp 3.0.8.
Thanks!
回答1:
echo $this->Form->time('released', [
'interval' => 15,
'hour' => [
'class' => 'foo-class',
],
'minute' => [
'class' => 'bar-class',
],
]);
prints=>
<select name="released[hour]" class="foo-class">
<option value="" selected="selected"></option>
<option value="00">0</option>
<option value="01">1</option>
<!-- .. snipped for brevity .. -->
<option value="22">22</option>
<option value="23">23</option>
</select>
<select name="released[minute]" class="bar-class">
<option value="" selected="selected"></option>
<option value="00">00</option>
<option value="15">15</option>
<option value="30">30</option>
<option value="45">45</option>
</select>
Reference - Cakebook3.x
来源:https://stackoverflow.com/questions/31318376/add-custom-class-to-cakephp-automagic-date-select