cakephp - 如何在 cakephp 中使用 Html->control() 添加类以选择标签
问题描述
有人知道如何添加类来选择标签吗?请帮我!
我目前有:
<?= $this->Form->control(
'tutor_profile.birthday',
[
'empty' => 'Choose...',
'minYear' => date('Y') - 100,
'maxYear' => date('Y')
]
);
?>
选择标签的创建方式如下:
<select name="tutor_profile[birthday][year]">...</select>
<select name="tutor_profile[birthday][month]">...</select>
<select name="tutor_profile[birthday][day]">...</select>
但我希望他们是这样的:
<select name="tutor_profile[birthday][year]" class="myClass">...</select>
<select name="tutor_profile[birthday][month]" class="myClass">...</select>
<select name="tutor_profile[birthday][day]" class="myClass">...</select>
我尝试添加['class' => 'myClass']
但没有用
解决方案
<?= $this->Form->control(
'tutor_profile.birthday',
[
'empty' => 'Choose...',
'minYear' => date('Y') - 100,
'maxYear' => date('Y'),
'class' => 'myClass', // <-------
]
);?>
https://github.com/cakephp/cakephp/blob/master/src/View/Helper/FormHelper.php#L155
'select' => '<select name="{{name}}"{{attrs}}>{{content}}</select>',
{{attrs}}
- 'id' => 'my_id'
- 'class' => 'my_class'
- '数据自定义' => '自定义值'
- ...
https://book.cakephp.org/3.0/en/views/helpers/form.html#creating-form-controls
推荐阅读
- python - 即使在笔记本电脑上播放良好,Kivy 声音也无法在 Android 设备上播放
- snowflake-cloud-data-platform - 如何在雪花中获取用户角色层次结构?
- apache-spark - NoClassDefFoundError:Solr 和 Spark Livy 中的 org/apache/solr/client/solrj/io/stream/expr/StreamExpressionParameter
- php - [Route: claim_card] [URI: admin/claim_card/{giftcard_id}/{layout_id}/{user_id}/{color_id}] 缺少必需的参数。- 拉拉维尔
- c# - 如何从 SQL Server 表中转换 TinyInt 值?
- javascript - 当我们提到 discord.js v12 时,如何让我的机器人做出响应?
- javascript - 通过 reducer 函数放置嵌套数组
- azure-application-insights - 大数据应用洞察
- docker - docker 容器在运行基准测试后丢失端口转发
- c# - 如果 Else 与布尔值结合不起作用