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


PHP bootstrap\ActiveForm类代码示例

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


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

示例1: generate

 /**
  * @param array $config
  * @return string
  */
 public static function generate($config = [])
 {
     $reservedAttributeNames = ['plainHTML'];
     ob_start();
     $form = ActiveForm::begin($config['formConfig']);
     foreach ($config['fields'] as $attribute => $fieldConfig) {
         if (in_array($attribute, $reservedAttributeNames)) {
             echo $fieldConfig;
         } else {
             if (isset($fieldConfig['render'])) {
                 $render = $fieldConfig['render'];
                 switch ($render['type']) {
                     case 'inline':
                         $method = $render['method'];
                         $options = isset($render['options']) ? $render['options'] : [];
                         echo $form->field($fieldConfig['model'], $attribute, isset($fieldConfig['options']) ? $fieldConfig['options'] : [])->{$method}($options);
                         break;
                     case 'widget':
                         $class = $render['class'];
                         $options = isset($render['options']) ? $render['options'] : [];
                         echo $form->field($fieldConfig['model'], $attribute, isset($fieldConfig['options']) ? $fieldConfig['options'] : [])->widget($class, $options);
                         break;
                 }
             } else {
                 echo $form->field($fieldConfig['model'], $attribute, isset($fieldConfig['options']) ? $fieldConfig['options'] : []);
             }
         }
     }
     ActiveForm::end();
     $result = ob_get_contents();
     ob_end_clean();
     return $result;
 }
开发者ID:bfday,项目名称:yii2-widget-form-generator,代码行数:37,代码来源:FormGenerator.php

示例2: layoutSelector

 /**
  * Scan directory with templates and show them in dropdown list
  *
  * @param \yii\bootstrap\ActiveForm $form
  *
  * @return string
  */
 public function layoutSelector($form)
 {
     $items = [];
     $pathToTemplates = Yii::getAlias('@app/templates/');
     Yii::$app->assetManager->publish($pathToTemplates);
     $assetUrl = Yii::$app->assetManager->getPublishedUrl($pathToTemplates);
     $layoutFolders = scandir($pathToTemplates);
     foreach ($layoutFolders as $layoutFolder) {
         if (!in_array($layoutFolder, ['.', '..']) && is_dir($pathToTemplates . $layoutFolder)) {
             $items[$layoutFolder] = Html::img($assetUrl . '/' . $layoutFolder . '/backend_image.png');
         }
     }
     return $form->field($this, 'layout')->radioList($items);
 }
开发者ID:webvimark,项目名称:ybc-content,代码行数:21,代码来源:ContentTemplate.php

示例3: actionUser

 /**
  * регистрация юзера по имейл
  * если регистрация для покупки, то передаются параметры рекомендатель и урл
  * @param type $affiliate_id
  * @param type $url_id
  * @return type
  * @throws \yii\web\NotFoundHttpException
  */
 public function actionUser($affiliate_id = null, $url_id = null)
 {
     $request = Yii::$app->request;
     $model = new \app\models\registration\UserForm();
     if ($request->isAjax && $model->load($request->post())) {
         Yii::$app->response->format = \yii\web\Response::FORMAT_JSON;
         return ActiveForm::validate($model);
     }
     if ($model->load($request->post()) && $model->validate()) {
         $user = User::findByUsername($model->email);
         if (!$user) {
             $user = $model->save();
         }
         $user->setCookie();
         if ($affiliate_id === null || $url_id === null) {
             Yii::$app->session->setFlash('success', 'Регистрация успешна. Пароль выслан на почту');
             return $this->goHome();
         }
         $url = Url::findOne($url_id);
         if (!$url) {
             throw new \yii\web\NotFoundHttpException('Урл не найден');
         }
         $user->purchase($affiliate_id, $url);
         return $this->redirect($url->link);
     }
     return $this->render('user', ['model' => $model]);
 }
开发者ID:nicdnepr,项目名称:skidos,代码行数:35,代码来源:RegistrationController.php

示例4: actionUser

 public function actionUser()
 {
     //make a db con or go back
     $db = new InstallConfig();
     try {
         $db->con();
     } catch (\yii\db\Exception $e) {
         return $this->render('config', array('model' => $db, "error" => "No DB"));
     }
     if (!User::find()->All() == null) {
         return $this->redirect('?r=install/finish');
         //Yii::$app->end();
     }
     //user
     $model = new User();
     $model->scenario = 'create';
     $model->language = 'he_il';
     $model->timezone = 'Asia/Jerusalem';
     if ($model->load(Yii::$app->request->post())) {
         //$model->save();
         if (Yii::$app->request->isAjax) {
             Yii::$app->response->format = \yii\web\Response::FORMAT_JSON;
             return \yii\bootstrap\ActiveForm::validate($model);
         }
         if ($model->save()) {
             $this->redirect('?r=install/finish');
         }
     }
     return $this->render('user', array('model' => $model));
 }
开发者ID:chaimvaid,项目名称:linet3,代码行数:30,代码来源:InstallController.php

示例5: saveData

 public function saveData()
 {
     if ($this->model->load(Yii::$app->request->post())) {
         if (Yii::$app->request->isAjax) {
             Yii::$app->response->format = Response::FORMAT_JSON;
             // perform AJAX validation
             echo ActiveForm::validate($this->model);
             Yii::$app->end();
             return '';
         }
         /** @var User|bool $registeredUser */
         $registeredUser = $this->model->register();
         if ($registeredUser !== false) {
             $module = UsersModule::module();
             // login registered user if there's no need in confirmation
             $shouldLogin = $module->allowLoginInactiveAccounts || $module->emailConfirmationNeeded === false;
             if ($module->emailConfirmationNeeded === true && $registeredUser->is_active) {
                 $shouldLogin = true;
             }
             if ($shouldLogin && $registeredUser->login(UsersModule::module()->loginDuration)) {
                 $returnUrl = Yii::$app->request->get('returnUrl');
                 if ($returnUrl !== null) {
                     return $this->controller->redirect($returnUrl);
                 }
             }
             return $this->controller->goBack();
         }
     }
     return '';
 }
开发者ID:cheaterBY,项目名称:yii2-users-module,代码行数:30,代码来源:Registration.php

示例6: actionValidateOptionsForm

 public function actionValidateOptionsForm()
 {
     $cOptFrm = new OptionsForm();
     if (Yii::$app->request->isAjax && $cOptFrm->load(Yii::$app->request->post())) {
         Yii::$app->response->format = Response::FORMAT_JSON;
         return ActiveForm::validate($cOptFrm);
     }
 }
开发者ID:Bibihelper,项目名称:Project2015,代码行数:8,代码来源:PrivateRoomController.php

示例7: run

 /**
  * @inheritdoc
  */
 public function run()
 {
     $form = ActiveForm::begin();
     echo $form->errorSummary($this->commentModel);
     echo $form->field($this->commentModel, 'title')->textInput(['maxlength' => true]);
     echo $form->field($this->commentModel, 'content')->textarea($this->textAreaOptions);
     echo Html::submitButton(empty($this->buttonLabel) ? Yii::t('app', 'Save') : $this->buttonLabel, $this->buttonOptions);
     ActiveForm::end();
 }
开发者ID:asinfotrack,项目名称:yii2-comments,代码行数:12,代码来源:CommentForm.php

示例8: run

 public function run()
 {
     $request = Yii::$app->getRequest();
     $this->modelComment = new BlogComment();
     if ($request->isAjax && $this->modelComment->load($request->post())) {
         Yii::$app->response->format = Response::FORMAT_JSON;
         $errors = ActiveForm::validate($this->modelComment);
         echo json_encode($errors);
     }
 }
开发者ID:sircovsw,项目名称:yii2-sslab-blog,代码行数:10,代码来源:Validate.php

示例9: run

 public function run()
 {
     parent::run();
     $model = new \app\models\ProjectSimpleForm();
     $form = ActiveForm::begin(['id' => 'project-simple-form', 'action' => ['/project/simplecreate'], 'layout' => 'inline', 'validateOnChange' => false, 'validateOnBlur' => false]);
     echo $form->field($model, 'title')->textInput(['maxlength' => 255, 'class' => 'form-control input-sm'])->label(false);
     echo '<div class="form-group">' . Html::submitButton(Yii::t('app', 'Create'), ['class' => 'btn btn-sm btn-success', 'style' => 'margin: 5px 5px 5px 0;']) . Html::resetButton(Yii::t('app', 'Cancel'), ['class' => 'btn btn-xs', 'style' => 'margin: 5px;']) . '</div>';
     ActiveForm::end();
     $this->registerJs();
 }
开发者ID:sizeg,项目名称:yii2-todo,代码行数:10,代码来源:SidebarProjectFormWidget.php

示例10: run

 public function run()
 {
     $this->options['class'] = 'ajax-form';
     parent::run();
     $content = ob_get_clean();
     return Html::tag('div', $content, ['class' => 'ajax-form-wrapper', 'style' => "max-width:{$this->maxWidth}px"]);
 }
开发者ID:promo-pr,项目名称:cms,代码行数:7,代码来源:AjaxForm.php

示例11: field

 public function field($model, $attribute, $options = [])
 {
     if (!isset($options['labelOptions']['label'])) {
         $options['labelOptions']['label'] = Html::encode($model->getAttributeLabel($attribute)) . ':';
     }
     return parent::field($model, $attribute, $options);
 }
开发者ID:semnt,项目名称:tp01,代码行数:7,代码来源:ActiveForm.php

示例12: init

 public function init()
 {
     $this->fieldConfig = ['template' => "<div class=\"row\">\n                <div class=\"col-xs-6\">{label}</div>\n                <div class=\"col-xs-6\"> <span class=\"tooltip-field pull-right\"> {hint} </span> <span class=\"tooltip-error-field pull-right\"> {error} </span> </div>\n            \n<div class=\"col-xs-12\">{input}</div>\n            </div>"];
     $this->fieldClass = ActiveField::className();
     echo Html::tag('span', AmosIcons::show('alert'), ['id' => 'errore-alert-common', 'class' => 'errore-alert bk-noDisplay', 'title' => \Yii::t('app', 'La tab contiene degli errori')]);
     parent::init();
 }
开发者ID:elitedivision,项目名称:amos-core,代码行数:7,代码来源:ActiveForm.php

示例13: init

 /**
  * @inheritdoc
  */
 public function init()
 {
     if ($this->pjax) {
         $this->options['data-pjax'] = 1;
     }
     parent::init();
 }
开发者ID:skoro,项目名称:yii2-admin-template,代码行数:10,代码来源:ActiveForm.php

示例14: run

 public function run()
 {
     ob_start();
     ob_implicit_flush(false);
     parent::run();
     ob_end_clean();
     echo Html::endTag('div');
 }
开发者ID:gromver,项目名称:yii2-models,代码行数:8,代码来源:ActiveForm.php

示例15: run

 public function run()
 {
     echo Html::endTag('div');
     $buttons = Html::tag('div', Html::submitButton(__('Search'), ['class' => 'btn btn-primary']));
     echo Html::tag('div', $buttons, ['class' => 'panel-footer ' . $this->extraClass . $this->targetClass]);
     echo Html::endTag('div');
     parent::run();
 }
开发者ID:vsguts,项目名称:crm,代码行数:8,代码来源:SearchForm.php


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