skeeks\cms\widgets\formInputs\selectTree\SelectTree::run PHP Method

run() public method

public run ( )
    public function run()
    {
        try {
            $this->_initAndValidate();
            $valueArray = [];
            $trees = [];
            $valueSingle = "";
            $select = "";
            $singleInput = "";
            if (in_array($this->mode, [self::MOD_COMBO, self::MOD_MULTI])) {
                $valueArray = Html::getAttributeValue($this->model, $this->attribute);
                $select = Html::activeListBox($this->model, $this->attribute, ['16' => "16"], ['multiple' => true, 'class' => 'sx-controll-element sx-multi', 'style' => 'display: none;']);
                $trees = Tree::find()->where(['id' => $valueArray])->all();
            }
            if (in_array($this->mode, [self::MOD_COMBO, self::MOD_SINGLE])) {
                $singleInput = Html::activeInput("hidden", $this->model, $this->attributeSingle, ['class' => 'sx-single']);
                $valueSingle = Html::getAttributeValue($this->model, $this->attributeSingle);
            }
            $src = UrlHelper::construct('/cms/admin-tools/tree')->set('mode', $this->mode)->setSystemParam(Module::SYSTEM_QUERY_EMPTY_LAYOUT, 'true')->setSystemParam(Module::SYSTEM_QUERY_NO_ACTIONS_MODEL, 'true')->enableAdmin()->toString();
            $id = "sx-id-" . md5(serialize([$this->clientOptions, $this->mode, $this->attributeMulti, $this->attributeSingle]));
            $selected = [];
            foreach ($trees as $tree) {
                $selected[] = $tree->id;
            }
            return $this->render('widget', ['widget' => $this, 'id' => $id, 'select' => $select, 'src' => $src, 'valueSingle' => $valueSingle, 'idSmartFrame' => $id . "-smart-frame", 'singleInput' => $singleInput, 'clientOptions' => Json::encode(['idSmartFrame' => $id . "-smart-frame", 'src' => $src, 'name' => $id, 'id' => $id, 'selected' => $selected, 'valueSingle' => $valueSingle])]);
            //$this->registerClientScript();
        } catch (Exception $e) {
            echo $e->getMessage();
        }
    }