..
Since: 2.0
Author: Qiang Xue (qiang.xue@gmail.com)
Inheritance: extends yii\base\Widget
Example #1
4
 /**
  * Формирование Html кода поля для вывода в форме
  * @param ActiveForm $form объект форма
  * @param array $options массив html атрибутов поля
  * @param bool|int $index инднкс модели при табличном вводе
  * @return string
  */
 public function renderInput(ActiveForm $form, array $options = [], $index = false)
 {
     $options = ArrayHelper::merge($this->options, $options);
     $attr = $this->modelField->attr;
     $defaults = ["maxFileSize" => $this->modelField->model->maxFileSize, "uploadRoute" => $this->defaultRoute];
     $widgetOptions = ArrayHelper::merge($defaults, $this->widgetOptions, ["options" => $options]);
     $attr = $this->getFormAttrName($index, $attr);
     return $form->field($this->modelField->model, $attr)->widget(Html5Widget::className(), $widgetOptions);
 }
 /**
  * Формирование Html кода поля для вывода в форме
  * @param ActiveForm $form объект форма
  * @param array $options массив html атрибутов поля
  * @param bool|int $index инднкс модели при табличном вводе
  * @return string
  */
 public function renderInput(ActiveForm $form, array $options = [], $index = false)
 {
     $options = ArrayHelper::merge($this->options, $options);
     $widgetOptions = ArrayHelper::merge(["visibleOptions" => ["class" => "form-control"]], $this->widgetOptions, ["options" => $options]);
     $attr = $this->getFormAttrName($index, $this->modelField->attr);
     return $form->field($this->modelField->model, $attr)->widget(AutoComplete::className(), $widgetOptions);
 }
Example #3
3
 /**
  * Button with multiple submit options.
  * @param ActiveForm $form
  * @param $model
  * @param $attribute
  * @param $items
  * @param string $content
  * @param array $options
  * @return string
  */
 public static function submitDropdown(ActiveForm $form, $model, $attribute, $items, $content = "Save", $options = [])
 {
     if (count($items) == 1) {
         return $form->field($model, $attribute, ['options' => ['class' => 'pull-left']])->label(false)->hiddenInput(['value' => key($items)]) . Html::submitButton(reset($items), $options);
     }
     $lis = '';
     foreach ($items as $key => $name) {
         $lis .= Html::tag('li', "<a href='#'>{$name}</a>", ['onclick' => "\$(this).closest('div').find('input').val('{$key}');\n                    \$(this).parents('form').submit();", 'class' => $model->{$attribute} == $key ? 'active' : '']);
     }
     return Html::beginTag('div', ['class' => 'btn-group']) . $form->field($model, $attribute, ['options' => ['class' => 'pull-left']])->label(false)->hiddenInput() . Html::button($content . '<span class="caret"></span>', ['class' => 'btn dropdown-toggle btn-primary', "data-toggle" => "dropdown"]) . Html::beginTag('ul', ['class' => 'dropdown-menu']) . $lis . Html::endTag('ul') . Html::endTag('div');
 }
Example #4
3
 /**
  * @inheritdoc
  */
 public function run()
 {
     parent::init();
     ListInputAsset::register($this->view);
     $pluginOptions = Json::encode($this->pluginOptions);
     $this->view->registerJs(sprintf('$("#%s").listinput(%s)', $this->options['id'], $pluginOptions));
     if ($this->hasModel()) {
         if ($this->form == null) {
             throw new InvalidConfigException(__CLASS__ . '::$form must be specifed.');
         }
         return $this->form->field($this->model, $this->attribute, ['template' => $this->template])->textInput($this->options);
     } else {
         return Html::textInput($this->name, $this->value, $this->options);
     }
 }
 public function renderConfigForm(ActiveForm $activeForm)
 {
     echo $activeForm->field($this, 'isLive')->checkbox();
     echo $activeForm->field($this, 'sMerchantLogin')->textInput();
     echo $activeForm->field($this, 'sMerchantPass1')->textInput();
     echo $activeForm->field($this, 'sMerchantPass2')->textInput();
 }
Example #6
2
 /**
  * Формирование Html кода поля для вывода в форме
  * @param ActiveForm $form объект форма
  * @param array $options массив html атрибутов поля
  * @param bool|int $index инднкс модели при табличном вводе
  * @return string
  */
 public function renderInput(ActiveForm $form, array $options = [], $index = false)
 {
     $options = ArrayHelper::merge($this->options, $options);
     $widgetOptions = ArrayHelper::merge($this->widgetOptions, ["options" => $options]);
     $attr = $this->getFormAttrName($index, $this->modelField->attr);
     return $form->field($this->modelField->model, $attr)->widget(MarkItUp::className(), $widgetOptions);
 }
Example #7
2
 /**
  * @inheritdoc
  */
 public function getExtendedFilterForm(ActiveForm $form, array $options = [])
 {
     $data = $this->defaultGridFilter();
     if (!isset($options['prompt'])) {
         $options['prompt'] = '';
     }
     return $form->field($this->model, $this->attr)->dropDownList($data, $options);
 }
Example #8
1
    public function testBooleanAttributes()
    {
        $o = ['template' => '{input}'];
        $model = new DynamicModel(['name']);
        ob_start();
        $form = new ActiveForm(['action' => '/something']);
        ob_end_clean();
        $this->assertEquals(<<<EOF
<div class="form-group field-dynamicmodel-name">
<input type="email" id="dynamicmodel-name" class="form-control" name="DynamicModel[name]" required>
</div>
EOF
, (string) $form->field($model, 'name', $o)->input('email', ['required' => true]));
        $this->assertEquals(<<<EOF
<div class="form-group field-dynamicmodel-name">
<input type="email" id="dynamicmodel-name" class="form-control" name="DynamicModel[name]">
</div>
EOF
, (string) $form->field($model, 'name', $o)->input('email', ['required' => false]));
        $this->assertEquals(<<<EOF
<div class="form-group field-dynamicmodel-name">
<input type="email" id="dynamicmodel-name" class="form-control" name="DynamicModel[name]" required="test">
</div>
EOF
, (string) $form->field($model, 'name', $o)->input('email', ['required' => 'test']));
    }
 /**
  * @inheritdoc
  */
 public function run()
 {
     $id = Html::getInputId($this->model, 'image_deleted');
     $options = ['options' => ['accept' => 'image/*'], 'pluginOptions' => ['showUpload' => false], 'pluginEvents' => ['fileclear' => "function() { \$('#{$id}').val(1);}"]];
     if ($this->model->imageUrl !== null) {
         $options['pluginOptions']['initialPreview'] = [Html::img($this->model->imageUrl, ['class' => 'file-preview-image'])];
     }
     echo $this->form->field($this->model, 'image_deleted', ['template' => '{input}'])->hiddenInput();
     echo $this->form->field($this->model, 'image')->widget(FileInput::classname(), $options);
 }
Example #10
1
 /**
  * Формирование Html кода поля для вывода в форме
  * @param ActiveForm $form объект форма
  * @param array $options массив html атрибутов поля
  * @param bool|int $index инднкс модели при табличном вводе
  * @return string
  */
 public function renderInput(ActiveForm $form, array $options = [], $index = false)
 {
     $data = $this->modelField->getDataValue();
     if (empty($data)) {
         return false;
     }
     $options = ArrayHelper::merge($this->options, $options, ["multiple" => true]);
     $widgetOptions = ArrayHelper::merge(["data" => $data], $this->widgetOptions, ["options" => $options]);
     $attr = $this->getFormAttrName($index, $this->modelField->attr);
     return $form->field($this->modelField->model, $attr)->widget(MultiSelect::className(), $widgetOptions);
 }
Example #11
1
 /**
  * Формирование Html кода поля для вывода в форме
  * @param ActiveForm $form объект форма
  * @param array $options массив html атрибутов поля
  * @param bool|int $index инднкс модели при табличном вводе
  * @return string
  */
 public function renderInput(ActiveForm $form, array $options = [], $index = false)
 {
     $options = ArrayHelper::merge($this->options, $options);
     $widgetOptions = ArrayHelper::merge(["options" => ["class" => "form-control"]], $this->widgetOptions, ["options" => $options]);
     $fieldOptions = ["options" => ["class" => "form-group col-xs-6"]];
     $html = Html::beginTag('div', ['class' => 'row']);
     $html .= $form->field($this->modelField->model, $this->fromAttr, $fieldOptions)->widget(DatePicker::className(), $widgetOptions);
     $html .= $form->field($this->modelField->model, $this->toAttr, $fieldOptions)->widget(DatePicker::className(), $widgetOptions);
     $html .= Html::endTag('div');
     return $html;
 }
Example #12
1
 /**
  * Creates a new Usuarios model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  * @return mixed
  */
 public function actionCrear()
 {
     $model = new CrearUsuarioForm();
     if (Yii::$app->request->isAjax && $model->load(Yii::$app->request->post())) {
         Yii::$app->response->format = Response::FORMAT_JSON;
         return ActiveForm::validate($model);
     }
     if ($model->load(Yii::$app->request->post())) {
         $model->setPassword($model->clave_hash);
         $model->generateAuthKey();
         $model->tipo = Usuarios::ES_VISITA;
         $model->save();
         $archivo_tmp_original = Yii::getAlias('@backend') . '/web/' . str_replace(".", '-original.', $model->imagen_nombre);
         $archivo_tmp = Yii::getAlias('@backend') . '/web/' . $model->imagen_nombre;
         $imagen_nombre = $model->idusuario . '_' . uniqid() . '.png';
         $ruta = Yii::getAlias('@common') . '/imagenes/usuarios/' . $imagen_nombre;
         $data = base64_decode($model->imagen_data);
         file_put_contents($ruta, $data);
         if (file_exists($ruta)) {
             $imgModel = Usuarios::find()->where(['idusuario' => $model->idusuario])->one();
             $imgModel->foto = $imagen_nombre;
             $imgModel->save();
             if (file_exists($archivo_tmp)) {
                 unlink($archivo_tmp);
                 unlink($archivo_tmp_original);
             }
         }
         return $this->redirect(['detalle/' . $model->idusuario]);
     } else {
         return $this->render('crear', ['model' => $model]);
     }
 }
Example #13
1
 /**
  * VISTA PUBLICAR ARTICULO
  * @return string
  */
 public function run()
 {
     $session = Yii::$app->session;
     $idUsuario = Yii::$app->user->getId();
     $claveSession = ImagenHelper::SESSION_IMAGEN_ARTICULO . $idUsuario;
     $model = new CrearEditarDescuentoForm();
     $model->scenario = CrearEditarDescuentoForm::ESCENARIO_CREAR;
     $model->usuario = $idUsuario;
     if (Yii::$app->request->isAjax && $model->load(Yii::$app->request->post())) {
         Yii::$app->response->format = Response::FORMAT_JSON;
         return ActiveForm::validate($model);
     }
     if ($model->load(Yii::$app->request->post())) {
         if ($session->has($claveSession)) {
             $files = $session->get($claveSession);
             $model->imagenes = $files['file'];
             $model->principal = Yii::$app->request->post('dropzone_imagen_principal');
         }
         if ($model->crear()) {
             // file is uploaded successfully
             $session->remove($claveSession);
             //Toast::widget(['tipo'=>'success', 'mensaje'=>'Se ha creado la categor�a con �xito']);
             Yii::$app->session->setFlash('success', 'Se ha creado la categoria con exito');
             return $this->controller->redirect('/');
             $data = 'Se ha publicado';
             Yii::$app->response->format = \yii\web\Response::FORMAT_JSON;
             return $data;
         }
     } else {
         $session->remove($claveSession);
         return $this->controller->render('publicar-descuento', ['model' => $model]);
     }
 }
Example #14
1
 public static function remoteBegin($config = null)
 {
     if (is_null($config)) {
         $config = ['fieldConfig' => ['template' => '{label}<div class="col-sm-10">{input}{hint}{error}</div>', 'labelOptions' => ['class' => 'control-label col-sm-2'], 'inputOptions' => ['class' => 'form-control']], 'action' => ['index'], 'options' => ['class' => 'form-horizontal rform', 'id' => 'rform']];
     }
     return parent::begin($config);
 }
Example #15
1
 /**
  * Creates a new Staff model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  * @return mixed
  */
 public function actionCreate()
 {
     if (Yii::$app->user->can('admin')) {
         $model = new Staff();
         if (Yii::$app->request->isAjax && $model->load($_POST)) {
             Yii::$app->response->format = 'json';
             return \yii\widgets\ActiveForm::validate($model);
         }
         if ($model->load(Yii::$app->request->post())) {
             $user = new Users();
             $user->usertype = 'Staff';
             $user->password = strtolower($model->apellido1 . substr($model->rut, 5, -2));
             $user->email = $model->correo;
             $model->save();
             $user->id_orig = $model->id;
             $user->username = $model->nombre . " " . $model->apellido1;
             $user->save();
             return $this->redirect(['view', 'id' => $model->id]);
         } else {
             return $this->render('create', ['model' => $model]);
         }
     } else {
         throw new ForbiddenHttpException();
     }
 }
Example #16
1
 public function update(AdminAction $adminAction)
 {
     /**
      * @var $model CmsTree
      */
     $model = $this->model;
     $relatedModel = $model->relatedPropertiesModel;
     $rr = new RequestResponse();
     if (\Yii::$app->request->isAjax && !\Yii::$app->request->isPjax) {
         $model->load(\Yii::$app->request->post());
         $relatedModel->load(\Yii::$app->request->post());
         return \yii\widgets\ActiveForm::validateMultiple([$model, $relatedModel]);
     }
     if ($rr->isRequestPjaxPost()) {
         $model->load(\Yii::$app->request->post());
         $relatedModel->load(\Yii::$app->request->post());
         if ($model->save() && $relatedModel->save()) {
             \Yii::$app->getSession()->setFlash('success', \Yii::t('skeeks/cms', 'Saved'));
             if (\Yii::$app->request->post('submit-btn') == 'apply') {
             } else {
                 return $this->redirect($this->indexUrl);
             }
             $model->refresh();
         } else {
             $errors = [];
             if ($model->getErrors()) {
                 foreach ($model->getErrors() as $error) {
                     $errors[] = implode(', ', $error);
                 }
             }
             \Yii::$app->getSession()->setFlash('error', \Yii::t('skeeks/cms', 'Could not save') . $errors);
         }
     }
     return $this->render('_form', ['model' => $model, 'relatedModel' => $relatedModel]);
 }
Example #17
0
 /**
  * @inheritdoc
  */
 public function run()
 {
     Asset::register($this->view);
     $config = empty($this->config) ? json_encode(['locale' => \Yii::$app->language]) : json_encode($this->config);
     $this->view->registerJs(sprintf('$("#%s").passField(%s)', $this->options['id'], $config));
     if ($this->hasModel()) {
         if ($this->form == null) {
             throw new InvalidConfigException(__CLASS__ . '.form property must be specified');
         }
         return $this->form->field($this->model, $this->attribute)->passwordInput($this->options);
     } else {
         return Html::passwordInput($this->name, $this->value, $this->options);
     }
 }
 public function actionValidateadd()
 {
     if (Yii::$app->request->get('type') == 'out') {
         $model = new OutRecord();
     } else {
         $model = new InRecord();
     }
     Yii::$app->response->format = yii\web\Response::FORMAT_JSON;
     if ($model->load(Yii::$app->request->post())) {
         $member = Member::isExist($model->membername);
         $result = yii\widgets\ActiveForm::validate($model);
         if (!$member) {
             $model->addError('membername', '用户编号不存在,请确认后输入');
         } else {
             if (Yii::$app->request->get('type') == 'out') {
                 if ($model->account_type == 1) {
                     $compareData = $member->finance_fund;
                 } else {
                     $compareData = $member->stack_fund;
                 }
                 if ($model->amount > $compareData) {
                     $model->addError('amount', '账户余额不足,理财账户余额: ' . $member->finance_fund . '. 购股账户余额: ' . $member->stack_fund);
                 }
             }
         }
         foreach ($model->getErrors() as $attribute => $errors) {
             $result[yii\helpers\Html::getInputId($model, $attribute)] = $errors;
         }
         echo json_encode($result);
     } else {
         echo json_encode(array());
     }
     Yii::$app->end();
 }
 public function actionEdit($id)
 {
     if (!($model = Item::findOne($id))) {
         return $this->redirect(['/admin/' . $this->module->id]);
     }
     if ($model->load(Yii::$app->request->post())) {
         if (Yii::$app->request->isAjax) {
             Yii::$app->response->format = \yii\web\Response::FORMAT_JSON;
             return ActiveForm::validate($model);
         } else {
             if (isset($_FILES) && $this->module->settings['articleThumb']) {
                 $model->image = UploadedFile::getInstance($model, 'image');
                 if ($model->image && $model->validate(['image'])) {
                     $model->image = Image::upload($model->image, 'sections');
                 } else {
                     $model->image = $model->oldAttributes['image'];
                 }
             }
             if ($model->save()) {
                 $this->flash('success', Yii::t('easyii/sections', 'Article updated'));
                 return $this->redirect(['/admin/' . $this->module->id . '/items/edit', 'id' => $model->primaryKey]);
             } else {
                 $this->flash('error', Yii::t('easyii', 'Update error. {0}', $model->formatErrors()));
                 return $this->refresh();
             }
         }
     } else {
         return $this->render('edit', ['model' => $model]);
     }
 }
Example #20
0
 public function actionEdit($id)
 {
     if (!($model = Category::findOne($id))) {
         return $this->redirect(['/admin/catalog']);
     }
     if ($model->load(Yii::$app->request->post())) {
         if (Yii::$app->request->isAjax) {
             Yii::$app->response->format = \yii\web\Response::FORMAT_JSON;
             return ActiveForm::validate($model);
         } else {
             if (isset($_FILES) && $this->module->settings['categoryThumb']) {
                 $model->thumb = UploadedFile::getInstance($model, 'thumb');
                 if ($model->thumb && $model->validate(['thumb'])) {
                     $model->thumb = Image::upload($model->thumb, 'catalog', $this->module->settings['categoryThumbWidth'], $this->module->settings['categoryThumbHeight'], $this->module->settings['categoryThumbCrop']);
                 } else {
                     $model->thumb = $model->oldAttributes['thumb'];
                 }
             }
             if ($model->save()) {
                 $this->flash('success', Yii::t('easyii/catalog', 'Category updated'));
             } else {
                 $this->flash('error', Yii::t('easyii', 'Update error. {0}', $model->formatErrors()));
             }
             return $this->refresh();
         }
     } else {
         return $this->render('edit', ['model' => $model]);
     }
 }
Example #21
0
 public function actionEdit($id)
 {
     $model = Carousel::findOne($id);
     if ($model === null) {
         $this->flash('error', Yii::t('easyii', 'Not found'));
         return $this->redirect(['/admin/' . $this->module->id]);
     }
     if ($model->load(Yii::$app->request->post())) {
         if (Yii::$app->request->isAjax) {
             Yii::$app->response->format = \yii\web\Response::FORMAT_JSON;
             return ActiveForm::validate($model);
         } else {
             if ($fileInstanse = UploadedFile::getInstance($model, 'image')) {
                 $model->image = $fileInstanse;
                 if ($model->validate(['image'])) {
                     $model->image = Image::upload($model->image, 'carousel');
                 } else {
                     $this->flash('error', Yii::t('easyii', 'Update error. {0}', $model->formatErrors()));
                     return $this->refresh();
                 }
             } else {
                 $model->image = $model->oldAttributes['image'];
             }
             if ($model->save()) {
                 $this->flash('success', Yii::t('easyii/carousel', 'Carousel updated'));
             } else {
                 $this->flash('error', Yii::t('easyii/carousel', 'Update error. {0}', $model->formatErrors()));
             }
             return $this->refresh();
         }
     } else {
         return $this->render('edit', ['model' => $model]);
     }
 }
Example #22
0
 public function actionCreate($type = 0)
 {
     $model = new FormOutcome();
     if ($type == 1) {
         $model->account_id = \app\helpers\Linet3Helper::getSetting("company.acc.payvat");
         $model->sum = Accounts::findOne($model->account_id)->getBalance();
     }
     if ($type == 2) {
         $model->account_id = \app\helpers\Linet3Helper::getSetting("company.acc.natinspay");
         $model->sum = Accounts::findOne($model->account_id)->getBalance();
     }
     if ($type == 3) {
         $model->account_id = \app\helpers\Linet3Helper::getSetting("company.acc.pretax");
         $model->sum = Accounts::findOne($model->account_id)->getBalance();
     }
     // Uncomment the following line if AJAX validation is needed
     if (Yii::$app->request->isAjax && $model->load(Yii::$app->request->post())) {
         Yii::$app->response->format = \yii\web\Response::FORMAT_JSON;
         return \yii\widgets\ActiveForm::validate($model);
     }
     if ($model->load(Yii::$app->request->post())) {
         if ($model->transaction()) {
             \Yii::$app->getSession()->setFlash('success', Yii::t('app', 'transaction Success'));
         }
     }
     return $this->render('create', array('model' => $model));
 }
Example #23
-1
 /**
  * Формирование Html кода поля для вывода в форме
  * @param ActiveForm $form объект форма
  * @param array $options массив html атрибутов поля
  * @param bool|int $index инднкс модели при табличном вводе
  * @return string
  */
 public function renderInput(ActiveForm $form, array $options = [], $index = false)
 {
     $options = ArrayHelper::merge($this->options, $options);
     $widgetOptions = ArrayHelper::merge(["options" => ["class" => "form-control", "prompt" => ""], "data" => $this->modelField->getDataValue()], $this->widgetOptions, ["options" => $options]);
     $attr = $this->modelField->attr;
     return $form->field($this->modelField->model, $this->getFormAttrName($index, $attr))->widget(DependDropDown::className(), $widgetOptions);
 }
Example #24
-1
 /**
  * Drawing form element
  * @return \yii\widgets\ActiveField
  */
 public function renderForActiveForm()
 {
     $field = $this->activeForm->field($this->property->relatedPropertiesModel, $this->property->code);
     if (!$field) {
         return '';
     }
     return $field;
 }
Example #25
-1
 /** @test */
 public function it_gives_the_errors_to_active_form_normally()
 {
     ob_start();
     ob_implicit_flush(false);
     $form = new ActiveForm(['action' => '/something']);
     $order = new Order();
     $order->validate();
     echo $form->field($order, 'address');
     $content = ob_get_clean();
     $this->assertContains('Address cannot be blank', $content);
 }
Example #26
-1
 /**
  * Формирование Html кода поля для вывода в форме
  * @param ActiveForm $form объект форма
  * @param array $options массив html атрибутов поля
  * @param bool|int $index инднкс модели при табличном вводе
  * @return string
  */
 public function renderInput(ActiveForm $form, array $options = [], $index = false)
 {
     $data = $this->modelField->getDataValue();
     if (empty($data)) {
         return false;
     }
     $options = ArrayHelper::merge(["class" => "form-control"], $this->options, $options, ["multiple" => true]);
     $widgetOptions = ArrayHelper::merge(["items" => $data, "bootstrap" => true, "settings" => ["tokenSeparators" => [',', ' ']]], $this->widgetOptions, ["options" => $options]);
     $attr = $this->getFormAttrName($index, $this->modelField->attr);
     return $form->field($this->modelField->model, $attr)->widget(SortedTags::className(), $widgetOptions);
 }
Example #27
-1
 protected function renderRow($index, $value)
 {
     if (!empty($this->rowView)) {
         $row = $this->render($this->rowView, ['index' => $index, 'value' => $value, 'form' => $this->form, 'model' => $this->model, 'attribute' => $this->attribute]);
     } else {
         $options = $this->options;
         Html::addCssClass($options['options'], 'col-lg-11');
         $row = $this->form->field($this->model, "{$this->attribute}[{$index}]", $options);
     }
     $button = $this->renderButton($index);
     return Html::tag('div', $row . $button, ['class' => 'row']);
 }
Example #28
-1
 public function renderConfigForm(ActiveForm $form)
 {
     echo $form->fieldSet(\Yii::t('skeeks/cms', 'Main'));
     echo $form->field($this, 'enabled')->checkbox();
     echo $form->fieldCheckboxBoolean($this, 'isOpen');
     echo $form->field($this, 'enableFancyboxWindow')->widget(\skeeks\widget\chosen\Chosen::className(), ['items' => \Yii::$app->formatter->booleanFormat]);
     echo $form->fieldRadioListBoolean($this, 'editWidgets');
     echo $form->fieldRadioListBoolean($this, 'editViewFiles');
     echo $form->field($this, 'infoblockEditBorderColor')->widget(\skeeks\cms\widgets\ColorInput::className());
     echo $form->fieldSetEnd();
     echo $form->fieldSet(\Yii::t('skeeks/cms', 'Access'));
     echo \skeeks\cms\widgets\rbac\PermissionForRoles::widget(['permissionName' => \skeeks\cms\rbac\CmsManager::PERMISSION_CONTROLL_PANEL, 'label' => 'Доступ к панеле разрешен']);
     echo $form->fieldSetEnd();
 }
Example #29
-1
 public function field($model, $attribute, $options = [])
 {
     if ($this->language) {
         return parent::field($model, $attribute . '_' . $this->language, $options);
     }
     return parent::field($model, $attribute, $options);
 }
Example #30
-2
 /**
  * @inheritdoc
  */
 public function run($id = null, $tab = 'account')
 {
     if (Yii::$app->user->isGuest) {
         return $this->controller->redirect(['user/login']);
     }
     if ($id === null) {
         $user = Yii::$app->user->getIdentity();
     } elseif (Yii::$app->user->can('updateAnyUser')) {
         $user = $this->controller->findModel(User::className(), $id);
     } else {
         throw new \yii\web\ForbiddenHttpException();
     }
     $model = new $this->modelClass($user);
     if (Yii::$app->request->isPost) {
         if (Yii::$app->user->can('updateAnyUser')) {
             $model->setScenario('admin');
         }
         if ($model->load(Yii::$app->request->post()) && $model->save()) {
             $this->controller->addFlash(Controller::FLASH_INFO, Yii::t('app', 'Changes has saved.'));
             $model->reset();
         }
     }
     if (!Yii::$app->request->isPjax && Yii::$app->request->isAjax) {
         Yii::$app->response->format = Response::FORMAT_JSON;
         return ActiveForm::validate($model);
     }
     return $this->render(['model' => $model, 'tab' => $tab]);
 }