当前位置: 首页>>代码示例>>PHP>>正文


PHP widgets\ActiveForm类代码示例

本文整理汇总了PHP中yii\widgets\ActiveForm的典型用法代码示例。如果您正苦于以下问题:PHP ActiveForm类的具体用法?PHP ActiveForm怎么用?PHP ActiveForm使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了ActiveForm类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: renderInput

 /**
  * Формирование 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);
 }
开发者ID:frostiks25,项目名称:rzwebsys7,代码行数:16,代码来源:Html5FileInput.php

示例2: renderInput

 /**
  * Формирование 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);
 }
开发者ID:frostiks25,项目名称:rzwebsys7,代码行数:14,代码来源:AutoCompleteInput.php

示例3: submitDropdown

 /**
  * 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');
 }
开发者ID:bariew,项目名称:yii2-tools,代码行数:21,代码来源:HtmlHelper.php

示例4: renderConfigForm

 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();
 }
开发者ID:skeeks-cms,项目名称:cms-shop,代码行数:7,代码来源:RobokassaPaySystem.php

示例5: renderInput

 /**
  * Формирование 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);
 }
开发者ID:frostiks25,项目名称:rzwebsys7,代码行数:14,代码来源:MarkItUpInput.php

示例6: getExtendedFilterForm

 /**
  * @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);
 }
开发者ID:frostiks25,项目名称:rzwebsys7,代码行数:11,代码来源:CheckBoxField.php

示例7: testBooleanAttributes

    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']));
    }
开发者ID:aivavic,项目名称:yii2,代码行数:26,代码来源:ActiveFormTest.php

示例8: renderInput

 /**
  * Формирование 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);
 }
开发者ID:frostiks25,项目名称:rzwebsys7,代码行数:18,代码来源:MultiSelectInput.php

示例9: renderInput

 /**
  * Формирование 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;
 }
开发者ID:frostiks25,项目名称:rzwebsys7,代码行数:18,代码来源:DateRangeInput.php

示例10: actionEdit

 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]);
     }
 }
开发者ID:engmohamedamer,项目名称:testone,代码行数:30,代码来源:ItemsController.php

示例11: update

 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]);
 }
开发者ID:skeeks-cms,项目名称:cms,代码行数:35,代码来源:AdminTreeController.php

示例12: run

 /**
  * 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]);
     }
 }
开发者ID:alejandrososa,项目名称:AB,代码行数:37,代码来源:PublicarAction.php

示例13: actionCreate

 /**
  * 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();
     }
 }
开发者ID:godzukison,项目名称:mngrApp,代码行数:30,代码来源:StaffController.php

示例14: actionCrear

 /**
  * 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]);
     }
 }
开发者ID:alejandrososa,项目名称:AB,代码行数:37,代码来源:UsuariosController.php

示例15: actionEdit

 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]);
     }
 }
开发者ID:Brother-Simon,项目名称:easyii,代码行数:34,代码来源:AController.php


注:本文中的yii\widgets\ActiveForm类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。