/
v.bolshakov
/
AIEcosystem-Testing
Обзор
Документация
Войти
/
v.bolshakov
/
AIEcosystem-Testing
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
CI/CD
Аналитика
Безопасность
dev
common/widgets/model/Filter.php
78 строк
2 KB
Developer
Initial commit
03 авг 2026, 17:43
03 авг 2026, 17:43
7433917
Код
Авторство
О чём код?
<?php namespace common\widgets\model; use common\helpers\ArrayHelper; use common\components\crud\FormCrud; use yii\bootstrap\Widget; /** * Отображение данных на редактирование * * @author Dmitry E. Semenov <sde.tomsk@gmail.com> * @copyright Self (c) 2020 */ class Filter extends Widget { /** * Базовый CRUD форма с которой работаем * * @var FormCrud */ public $crud = null; /** * Модель с которой работаем * * @var null */ public $model = null; /** * Действие(необязтельный параметр, указываем если нужно делать переход на определенную страницу) * * @var null */ public $action = '#'; /** * Кнопка "Очистить фильтр", по умалчанию всегда есть, при необходимости скрыть в данную переменную передаем false * * @var bool */ public $clear_button = true; /** * @inheritdoc */ public function run() { $fields = $this->crud->fields(); if ($act = $this->crud->formAction) { ($this->action = $act); } $rows = []; $the_index = 0; foreach ($fields as $name => $field) { $row = ArrayHelper::getValue($field, 'options.row', 1); $col = ArrayHelper::getValue($field, 'options.col', 1); $index = ArrayHelper::getValue($field, 'options.index', $the_index); $rows[$row][$col][$index][] = [ 'name' => $name, 'field' => $field ]; $the_index += 10; } ArrayHelper::ksortRecursive($rows); return $this->render('filter', [ 'crud' => $this->crud, 'model' => $this->model, 'action' => $this->action, 'rows' => $rows, 'clear_button' => $this->clear_button ]); } }