Answer the question
In order to leave comments, you need to log in
How to make an array element display in html format?
There is a function like this:
public static function getStatusList()
{
return ["<span class='text-danger'>Активен</span>", "<span class='text-success'>Завершен</span>"];
}
Answer the question
In order to leave comments, you need to log in
Good evening.
In the model:
const STATUS_BLOCKED = 0;
const STATUS_ACTIVE = 1;
/**
* @return mixed
*/
public function getStatusName()
{
return ArrayHelper::getValue(self::getStatusesArray(), $this->status);
}
/**
* @return array
*/
public static function getStatusesArray()
{
return [
self::STATUS_ACTIVE => 'Активен',
self::STATUS_BLOCKED => 'Завершён'
];
}
'value' => Html::tag('span',
$model->getStatusName(),
['class' => 'label label-' . ArrayHelper::getValue([0 => 'danger', 1 => 'success'], $model->status)])
]
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question