public function testItems() { $this->specify("Попытка получить список операторов", function () { $items = ['operator1' => 'Оператор 1', 'operator2' => 'Оператор 2']; expect("Список должен состоять из пар идентификатор - имя", Operator::items())->equals($items); }); }
var formatEmployeeList = function(item) { return '<b>' + item.name + '</b><p><small>' + item.post + ' (' + item.division + ')</small></p>'; } var formatEmployeeSelection = function (employee) { return employee.name || employee.text; } JS; $this->registerJs($formatJs, View::POS_HEAD); ?> <?php echo $form->field($model, 'ownerId')->widget(\kartik\select2\Select2::className(), ['initValueText' => $model->owner->fullName, 'showToggleAll' => false, 'options' => ['placeholder' => 'Имя сотрудника...'], 'pluginOptions' => ['allowClear' => true, 'minimumInputLength' => 3, 'ajax' => ['url' => \yii\helpers\Url::to(['owner-list']), 'dataType' => 'json', 'data' => new JsExpression('function(params) { return {q:params.term}; }'), 'delay' => 250], 'escapeMarkup' => new JsExpression('function (markup) { return markup; }'), 'templateResult' => new JsExpression('formatEmployeeList'), 'templateSelection' => new JsExpression('formatEmployeeSelection')]]); ?> <?php echo $form->field($model, 'operatorId')->dropDownList(Operator::items()); ?> <?php echo ActiveRadioList::widget(['activeField' => $form->field($model, 'destination'), 'items' => $model::destinationItems(), 'options' => ['class' => 'btn-group btn-group-sm']]); ?> <?php echo $form->field($model, 'limit', ['enableClientValidation' => true]); ?> <?php echo $form->field($model, 'options')->checkboxList($model::optionItems()); ?> <?php
public static function getOperatorItems() { if (self::$operatorList === null) { self::$operatorList = array_merge([self::OPERATOR_ALL => "Все операторы"], Operator::items()); } return self::$operatorList; }
public function getOperators() { return array_merge([self::OPERATOR_ANY => 'Выберите оператора'], Operator::items()); }
public static function operatorList() { return Operator::items(); }