Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/drupal/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php Html标记在Yii2中的模型属性标签内不起作用_Php_Forms_Activerecord_Yii2 - Fatal编程技术网

Php Html标记在Yii2中的模型属性标签内不起作用

Php Html标记在Yii2中的模型属性标签内不起作用,php,forms,activerecord,yii2,Php,Forms,Activerecord,Yii2,Html标记在Yii2中的模型属性标签内不起作用 public function attributeLabels() { return [ 'name'=>' Name <br> Age', ]; } 上面的一个是实际代码….$form->field($model,'termsofuse')) $form->field($model, 'termsofuse') ->checkbox

Html标记在Yii2中的模型属性标签内不起作用

  public function attributeLabels() {
            return [
       'name'=>' Name <br> Age',
            ];
        }
上面的一个是实际代码….

$form->field($model,'termsofuse'))
$form->field($model, 'termsofuse')
->checkbox(['label' => Yii::t('app', 'I understand and agree to the <a href="#termsofuse">Terms of Use</a>.')])
->label(false);
->复选框(['label'=>Yii::t('app','I理解并同意'.')) ->标签(假);

更多信息,请正确缩进代码,这很难理解。当然,我现在已经编辑过了。请尝试使用
\n
而不是
并将您的值用双引号而不是单引号括起来这是什么原因?为什么标签上有两个名称,如
Name
Age
?假设实体的每个属性都有一个标签。模型中不应该有任何html属性。这必须在视图文件中处理。尝试过了,\n标记没有出现在UI中,但它没有中断线路,但不会出现在验证消息中,如下面所示,“我理解并同意不能为空”。。它附带了HTML标签
$form->field($model, 'termsofuse')
->checkbox(['label' => Yii::t('app', 'I understand and agree to the <a href="#termsofuse">Terms of Use</a>.')])
->label(false);