【发布时间】:2020-07-05 04:44:53
【问题描述】:
Html 标签在 Yii2 中的模型属性标签内不起作用
public function attributeLabels() {
return [
'name'=>' Name <br> Age',
];
}
Br 标记在那里不起作用,它在 UI 中显示
标记。
public function attributeLabels() {
$labels = [
'id' => 'ID',
'model_id' => 'Form Name',
'user_id' => 'User Name',
];
$model = $this->getFields(UcFormFields::STATIC_FIELDS);
foreach ($model as $field)
$labels[$field->varname] = Yii::t('app', $field->title);
$model = $this->getFields(UcFormFields::DYNAMIC_FIELDS);
foreach ($model as $field)
$labels[$field->varname] = "Question \n Instruction.."; // will be replaced by variable
$model = $this->getDepFields(UcFormFields::DYNAMIC_FIELDS);
foreach ($model as $field)
$labels[$field->varname] = Yii::t('app', $field->title);
return $labels;
}
以上是实际代码....
【问题讨论】:
-
请正确缩进你的代码,很难理解。
-
好的,我现在已经编辑过了。
-
尝试使用
\n代替
并将您的值封装在双引号而不是单引号中 -
这是什么原因?为什么你的标签有两个名字,比如
Name和Age?实体的每个属性都假设有一个标签。而且你不应该在模型中有任何 html 属性。这必须在视图文件中处理。 -
试过了,UI中没有出现\n标签,但是没有断线
标签: php forms activerecord yii2