<commit_before><?php

/*
 * HiPanel core package
 *
 * @link      https://hipanel.com/
 * @package   hipanel-core
 * @license   BSD-3-Clause
 * @copyright Copyright (c) 2014-2016, HiQDev (http://hiqdev.com/)
 */

namespace hipanel\widgets;

use hipanel\models\Ref;
use hiqdev\hiart\ActiveRecord;
use yii\base\Widget;
use yii\helpers\ArrayHelper;
use yii\helpers\Html;

/**
 * Class RefFilter widget.
 *
 * Usage:
 * Label::widget([
 *      'attribute' => 'state',
 *      'model'     => $searchModel,
 *      'gtype'     => 'state,domain',
 * ]);
 */
class RefFilter extends Widget
{
    /**
     * @var ActiveRecord
     */
    public $model;

    /**
     * @var string
     */
    public $gtype;

    /**
     * @var array additional find options that will be passed to [[Ref]] model
     */
    public $findOptions = [];

    /**
     * @var string
     */
    public $attribute;

    /**
     * @var array
     */
    public $options = [];

    public static function widget($config = [])
    {
        if (isset($config['options'])) {
            $options = &$config['options'];
        }
        $vars = get_class_vars(get_class());
        foreach ($config as $k => $v) {
            if (array_key_exists($k, $vars)) {
                continue;
            }
            $options[$k] = $v;
            unset($config[$k]);
        }
        return parent::widget($config);
    }

    public function run()
    {
        parent::run();
        return $this->renderInput();
    }

    protected function renderInput()
    {
        echo Html::activeDropDownList($this->model, $this->attribute, Ref::getList($this->gtype, $this->findOptions), ArrayHelper::merge([
            'class'     => 'form-control',
            'prompt'    => \Yii::t('app', '----------'),
        ], $this->options));
    }
}<commit_msg>fixed RefFilter to work properfly as ActiveField widget<commit_after><?php

/*
 * HiPanel core package
 *
 * @link      https://hipanel.com/
 * @package   hipanel-core
 * @license   BSD-3-Clause
 * @copyright Copyright (c) 2014-2016, HiQDev (http://hiqdev.com/)
 */

namespace hipanel\widgets;

use hipanel\models\Ref;
use hiqdev\hiart\ActiveRecord;
use yii\base\Widget;
use yii\helpers\ArrayHelper;
use yii\helpers\Html;

/**
 * Class RefFilter widget.
 *
 * Usage:
 * Label::widget([
 *      'attribute' => 'state',
 *      'model'     => $searchModel,
 *      'gtype'     => 'state,domain',
 * ]);
 */
class RefFilter extends Widget
{
    /**
     * @var ActiveRecord
     */
    public $model;

    /**
     * @var string
     */
    public $gtype;

    /**
     * @var array additional find options that will be passed to [[Ref]] model
     */
    public $findOptions = [];

    /**
     * @var string
     */
    public $attribute;

    /**
     * @var array
     */
    public $options = [];

    public static function widget($config = [])
    {
        if (isset($config['options'])) {
            $options = &$config['options'];
        }
        $vars = get_class_vars(get_class());
        foreach ($config as $k => $v) {
            if (array_key_exists($k, $vars)) {
                continue;
            }
            $options[$k] = $v;
            unset($config[$k]);
        }
        return parent::widget($config);
    }

    public function run()
    {
        parent::run();
        return $this->renderInput();
    }

    protected function renderInput()
    {
        return Html::activeDropDownList($this->model, $this->attribute, Ref::getList($this->gtype, $this->findOptions), ArrayHelper::merge([
            'class'     => 'form-control',
            'prompt'    => \Yii::t('app', '----------'),
        ], $this->options));
    }
}
{'fraction_non_alphanumeric': 0.1719260065288357, 'fraction_numerical': 0.004896626768226333, 'mean_word_length': 1.999184339314845, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 27, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5598562', 'n_tokens_mistral': 1163, 'n_tokens_neox': 1143, 'n_words': 241}