You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

46 lines
903 B

6 years ago
<?php
/**
* Created by Error202
* Date: 29.07.2018
*/
namespace common\modules\forms\helpers;
use common\modules\forms\entities\Form;
use Yii;
use yii\helpers\ArrayHelper;
use yii\helpers\Html;
class FormHelper {
public static function statusList(): array
{
return [
Form::STATUS_DRAFT => Yii::t('form', 'Draft'),
Form::STATUS_ACTIVE => Yii::t('form', 'Active'),
];
}
public static function statusName($status): string
{
return ArrayHelper::getValue(self::statusList(), $status);
}
public static function statusLabel($status): string
{
switch ($status) {
case Form::STATUS_DRAFT:
$class = 'label label-default';
break;
case Form::STATUS_ACTIVE:
$class = 'label label-success';
break;
default:
$class = 'label label-default';
}
return Html::tag('span', ArrayHelper::getValue(self::statusList(), $status), [
'class' => $class,
]);
}
}