Cakephp3 : Render/Evaluate HTML inside label formhelper

标签 cakephp cakephp-3.0

如何在 cakephp3 中将 html 放置在标签内?

我需要实现 * 姓名:

使用下面的代码

<?php
    echo $this->Form->input ( 'name', [ 
            'label' => [ 
                    'text' => '<span class="red">*</span> Name:',
                    'class' => 'col-sm-12 col-md-2 col-lg-1 control-label' 
            ],
            'class' => 'form-control',
            'rows' => 1 
    ] );

最佳答案

与往常一样,使用 escape option .

echo $this->Form->input('name', [ 
    'label' => [ 
        // ...
        'escape' => false
    ],
    // ...
]);

关于Cakephp3 : Render/Evaluate HTML inside label formhelper,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27991447/

相关文章:

php - CakePHP:尝试生成模式时出错

mysql - CakePHP 1.3 : How to represent the following MySQL code with Count(*) AS Total

php - 蛋糕PHP : separate database access for admin users

cakephp 3 order by query 生成 14 个带有关联表的查询而不是 1 个

cakephp - CakePHP 3 上未找到类 'Locale' 问题

CakePHP 3 - beforeSave 回调在编辑时不起作用

PHP 警告 : include(/var/www/html/. ...../lib/Cake/Error/ErrorHandler.php): 无法打开流错误

php - Gmail自动登录脚本

css - Bootstrap Glyphicons 未在 Cakephp 中显示

找不到 cakephp3 类 DateTime