在 kartik activeform 中使用字体真棒 - yii2
font awesome use in kartik activeform - yii2
我在 Yii2 开发中使用了 kartik 活动表单,所以我想将图标添加到表单字段中。我跟着这个 LINK 并尝试了下面的编码
//注册字体真棒
rmrevin\yii\fontawesome\AssetBundle::register($this);
<?php $form = ActiveForm::begin();
<?= $form->field($model, 'Bags_count',[
'feedbackIcon' => [
'default' => 'sort-numeric-desc',
'success' => 'ok',
'error' => 'exclamation-sign',
]
])->textInput()->hint(' Example: 4'); ?>
<?php ActiveForm::end(); ?>
我使用 chrome 检查元素功能发现了这种不需要的编码。希望这对答案有帮助。
您可以更改小部件功能以使用 font-awesome-class
protected function renderFeedbackIcon()
{
if (!$this->_hasFeedback) {
return '';
}
$config = $this->feedbackIcon;
$type = ArrayHelper::getValue($config, 'type', 'icon');
$prefix = ArrayHelper::getValue($config, 'prefix', 'fa fa-');
$id = Html::getInputId($this->model, $this->attribute);
return $this->getFeedbackIcon($config, 'default', $type, $prefix, $id) .
$this->getFeedbackIcon($config, 'success', $type, $prefix, $id) .
$this->getFeedbackIcon($config, 'error', $type, $prefix, $id);
}
我在 Yii2 开发中使用了 kartik 活动表单,所以我想将图标添加到表单字段中。我跟着这个 LINK 并尝试了下面的编码
//注册字体真棒
rmrevin\yii\fontawesome\AssetBundle::register($this);
<?php $form = ActiveForm::begin();
<?= $form->field($model, 'Bags_count',[
'feedbackIcon' => [
'default' => 'sort-numeric-desc',
'success' => 'ok',
'error' => 'exclamation-sign',
]
])->textInput()->hint(' Example: 4'); ?>
<?php ActiveForm::end(); ?>
我使用 chrome 检查元素功能发现了这种不需要的编码。希望这对答案有帮助。
您可以更改小部件功能以使用 font-awesome-class
protected function renderFeedbackIcon()
{
if (!$this->_hasFeedback) {
return '';
}
$config = $this->feedbackIcon;
$type = ArrayHelper::getValue($config, 'type', 'icon');
$prefix = ArrayHelper::getValue($config, 'prefix', 'fa fa-');
$id = Html::getInputId($this->model, $this->attribute);
return $this->getFeedbackIcon($config, 'default', $type, $prefix, $id) .
$this->getFeedbackIcon($config, 'success', $type, $prefix, $id) .
$this->getFeedbackIcon($config, 'error', $type, $prefix, $id);
}