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


PHP Html::errorSummary方法代码示例

本文整理汇总了PHP中yii\helpers\Html::errorSummary方法的典型用法代码示例。如果您正苦于以下问题:PHP Html::errorSummary方法的具体用法?PHP Html::errorSummary怎么用?PHP Html::errorSummary使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在yii\helpers\Html的用法示例。


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

示例1: run

 public function run()
 {
     $items = [];
     $preContent = '';
     $isPost = \Yii::$app->request->isPost;
     $defaultLang = Lang::getLang()->code;
     foreach ($this->models as $k => $model) {
         $preContent .= $isPost && !$model->validate() ? '<div class="alert alert-warning" role="alert"><button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">&times;</span></button><h4>' . $model->langModel->title . '</h4>' . Html::errorSummary($model) . '</div>' : '';
         $content = $this->view->render($this->template, ['model' => $model, 'k' => $k, 'form' => $this->form]);
         $items[] = ['label' => $model->langModel->title, 'content' => $content, 'active' => $model->lang == $defaultLang];
     }
     return $preContent . Tabs::widget(['items' => $items]);
 }
开发者ID:ivphpan,项目名称:gwm,代码行数:13,代码来源:LanguageTabs.php

示例2: errorSummary

 public static function errorSummary($models, $options = array())
 {
     $newOptions = ['class' => 'alert alert-danger'];
     $options = array_merge($options, $newOptions);
     $html = parent::errorSummary($models, $options);
     return $html;
 }
开发者ID:karczmarczyk,项目名称:photo-archive,代码行数:7,代码来源:Html.php

示例3: run

 public function run($id)
 {
     $id = (int) $id;
     $userId = Adver::getUserIdFromAdver($id);
     $output = [];
     if ($userId != Yii::$app->getUser()->id) {
         $output = ['error' => true, 'message' => '<div class="alert alert-danger">' . Yii::t('app', 'The requested page does not exist.') . '</div>'];
     }
     if (empty($output) && !Gallery::checkLimitation($id)) {
         $output = ['error' => true, 'message' => '<div class="alert alert-danger">' . Yii::t('app', 'Image limitation per advertisement reached!') . '</div>'];
     }
     if (empty($output)) {
         $model = new Gallery(['scenario' => 'new']);
         if ($model->load(Yii::$app->request->post())) {
             $model->image = UploadedFile::getInstance($model, 'image');
             if ($model->image) {
                 $model->name = Yii::$app->helper->safeFile($model->image->baseName) . '-' . Yii::$app->getSecurity()->generateRandomString(6) . '-' . time() . '.' . $model->image->extension;
                 $path = $model->getImagePath($id) . DIRECTORY_SEPARATOR . $model->name;
                 $path = FileHelper::normalizePath($path);
                 $model->adver_id = $id;
                 if ($model->validate() && $model->image->saveAs($path, false)) {
                     if ($model->save()) {
                         $output = ['error' => false, 'message' => '<div class="alert alert-success">' . Yii::t('app', 'Image saved!') . '</div>'];
                     } else {
                         $output = ['error' => true, 'message' => '<div class="alert alert-danger">' . Yii::t('app', 'Error on saving image.') . '</div>'];
                     }
                 }
             }
         }
         if (empty($output)) {
             $output = ['error' => true, 'message' => \yii\helpers\Html::errorSummary($model, ["class" => "alert alert-danger"])];
         }
     }
     return \yii\helpers\Json::encode($output);
 }
开发者ID:rocketyang,项目名称:admap,代码行数:35,代码来源:GalleryAdd.php

示例4: setFlashError

 /**
  * @param Model|string $message
  */
 public static function setFlashError($message)
 {
     if ($message instanceof Model) {
         $message = Html::errorSummary($message);
     }
     self::setFlash('error', $message);
 }
开发者ID:carono,项目名称:yii2-components,代码行数:10,代码来源:CurrentUser.php

示例5: throwNewException

 public function throwNewException($title)
 {
     if (!is_null($this)) {
         $title = '<h4>' . $title . '</h4>';
     }
     $options = ['header' => $title, 'footer' => ''];
     throw new Exception(Html::errorSummary($this, $options));
 }
开发者ID:albertborsos,项目名称:yii2-lib,代码行数:8,代码来源:ActiveRecord.php

示例6: actionSearch

 /**
  * @return \yii\web\Response
  */
 public function actionSearch()
 {
     $model = new RedisModel();
     if ($model->load(\Yii::$app->request->post()) && $model->storeFilter()) {
         \Yii::$app->session->setFlash('success', Redisman::t('redisman', 'Search query updated!'));
         return $this->redirect(['show']);
     } else {
         \Yii::$app->session->setFlash('error', Html::errorSummary($model));
         return $this->redirect(['index']);
     }
 }
开发者ID:insolita,项目名称:yii2-redisman,代码行数:14,代码来源:DefaultController.php

示例7: setAjaxData

 /**
  * Validate Form action
  * @param Model $model
  * @param string $action
  * @return array
  */
 public function setAjaxData(Model $model, $action = 'save', $json = false)
 {
     $response = ['status' => 0, 'errors' => '', 'text' => ''];
     if (\Yii::$app->request->isAjax && $model->load(\Yii::$app->request->post())) {
         if ($model->{$action}()) {
             $response['status'] = 1;
         } else {
             $response['errors'] = Html::errorSummary($model);
         }
     }
     return $json ? json_encode($response) : [$model, $response];
 }
开发者ID:h11Nox,项目名称:slug,代码行数:18,代码来源:ActionWidget.php

示例8: actionAddComment

 public function actionAddComment()
 {
     $productId = Yii::$app->request->post('productId');
     $rank = Yii::$app->request->post('rank');
     $content = Yii::$app->request->post('content');
     $comment = new Comment();
     $comment->attributes = ['product_id' => $productId, 'user_id' => Yii::$app->user->identity->id, 'rank' => $rank, 'content' => $content];
     if ($comment->save(true)) {
         return ['status' => true, 'message' => '成功'];
     } else {
         return ['status' => false, 'message' => '失败: ' . Html::errorSummary($comment)];
     }
 }
开发者ID:su-xiaolin,项目名称:ICShop-Yii,代码行数:13,代码来源:ProductController.php

示例9: actionImport

 public function actionImport()
 {
     $model = new ModificatorUpload();
     if ($model->load($_POST)) {
         $model->file = UploadedFile::getInstance($model, 'file');
         if (Yii::$app->request->isAjax) {
             Yii::$app->response->format = Response::FORMAT_JSON;
             return ActiveForm::validate($model);
         }
         if ($model->import()) {
             return $this->redirect(['/store/admin/product/update', 'id' => $model->productId, 'tab' => 'modificator']);
         }
     }
     echo Html::errorSummary($model);
 }
开发者ID:nurastana,项目名称:familyclinickz,代码行数:15,代码来源:ModificatorcategoryController.php

示例10: registerUser

 /** 
  * Registers a user
  * @param $data
  * @return Bool
  */
 private function registerUser($data)
 {
     $userModel = new User();
     $userModel->scenario = 'registration';
     $profileModel = $userModel->profile;
     $profileModel->scenario = 'registration';
     // User: Set values
     $userModel->username = $data['username'];
     $userModel->email = $data['email'];
     $userModel->group_id = $data['group_id'];
     $userModel->status = User::STATUS_ENABLED;
     // Profile: Set values
     $profileModel->firstname = $data['firstname'];
     $profileModel->lastname = $data['lastname'];
     // Password: Set values
     $userPasswordModel = new Password();
     $userPasswordModel->setPassword($data['password']);
     if ($userModel->save()) {
         // Save user profile
         $profileModel->user_id = $userModel->id;
         $profileModel->save();
         // Save user password
         $userPasswordModel->user_id = $userModel->id;
         $userPasswordModel->save();
         // Join space / create then join space
         foreach ($data['space_names'] as $key => $space_name) {
             // Find space by name attribute
             $space = Space::findOne(['name' => $space_name]);
             // Create the space if not found
             if ($space == null) {
                 $space = new Space();
                 $space->name = $space_name;
                 $space->save();
             }
             // Add member into space
             $space->addMember($userModel->id);
         }
         return true;
     } else {
         Yii::$app->session->setFlash('error', Html::errorSummary($userModel));
         return false;
     }
 }
开发者ID:ConnectedCommunities,项目名称:humhub-modules-bulk_import,代码行数:48,代码来源:MainController.php

示例11: actionCreate

 /**
  * @inheritdoc
  */
 public function actionCreate()
 {
     $model = new Dump($this->getModule()->dbList, $this->getModule()->customDumpOptions);
     if ($model->load(Yii::$app->request->post()) && $model->validate()) {
         $dbInfo = $this->getModule()->getDbInfo($model->db);
         $dumpOptions = $model->makeDumpOptions();
         $manager = $this->getModule()->createManager($dbInfo);
         $dumpPath = $manager->makePath($this->getModule()->path, $dbInfo, $dumpOptions);
         $dumpCommand = $manager->makeDumpCommand($dumpPath, $dbInfo, $dumpOptions);
         Yii::trace(compact('dumpCommand', 'dumpPath', 'dumpOptions'), get_called_class());
         if ($model->runInBackground) {
             $this->runProcessAsync($dumpCommand);
         } else {
             $this->runProcess($dumpCommand);
         }
     } else {
         Yii::$app->session->setFlash('error', Yii::t('dbManager', 'Dump request invalid.') . '<br>' . Html::errorSummary($model));
     }
     return $this->redirect(['index']);
 }
开发者ID:beaten-sect0r,项目名称:yii2-db-manager,代码行数:23,代码来源:DefaultController.php

示例12: actionAdd

 public function actionAdd()
 {
     $addModel = new SourceMessage();
     $sourceMessage = SourceMessage::find()->where(['category' => Yii::$app->request->post('categoryId'), 'message' => Yii::$app->request->post('SourceMessage')['message']])->one();
     if (empty($sourceMessage)) {
         if ($addModel->load(Yii::$app->request->post()) && $addModel->validate()) {
             $addModel->category = !empty($messageCategory) ? $messageCategory->category : Yii::$app->request->post('categoryId');
             if (empty($addModel->category)) {
                 Yii::$app->session->setFlash('error', 'Category empty');
                 return $this->redirect(Yii::$app->request->referrer);
             }
             $addModel->save();
             Yii::$app->session->setFlash('success', 'Data success created.');
         } else {
             Yii::$app->session->setFlash('error', Html::errorSummary($addModel));
         }
     } else {
         Yii::$app->session->setFlash('error', 'Such category already exists.');
     }
     return $this->redirect(Yii::$app->request->referrer);
 }
开发者ID:black-lamp,项目名称:blcms-translate,代码行数:21,代码来源:MessageController.php

示例13: actionSendApiRequest

 /**
  * Send request to Teleduino API and return HTML formatted response.
  *
  * @throws HttpException if invalid method was specified.
  */
 public function actionSendApiRequest()
 {
     $api = $this->module->api;
     $requestPostData = Yii::$app->request->post($api->getRequestModelClass());
     $method = isset($requestPostData['r']) ? $requestPostData['r'] : '';
     try {
         $model = $api->createAndConfigureRequestModel($method);
     } catch (\Exception $e) {
         throw new HttpException(400, "Invalid method: {$method}.");
     }
     if (!($model->load(Yii::$app->request->post()) && $model->validate())) {
         return Html::errorSummary($model);
     }
     // If user selected RAW(JSON) response format
     if ('pretty' !== Yii::$app->request->post('response_formatting')) {
         try {
             $responseText = $api->requestRawFromModel($model);
         } catch (\Exception $e) {
             $responseText = 'Error: ' . $e->getMessage();
         }
         return $this->renderPartial('_responseRaw', ['rawResponse' => $responseText]);
     }
     $success = false;
     $time = null;
     try {
         $response = $api->requestFromModel($model);
         if ($response->isSuccessful()) {
             $success = true;
             $message = $api->formatResponseValuesHtml($method, $response->getValues());
             $time = $response->getTime();
         } else {
             $message = nl2br($response->getErrorMessage());
         }
     } catch (\Exception $e) {
         $message = 'Error: ' . $e->getMessage();
     }
     return $this->renderPartial('_responsePretty', ['success' => $success, 'message' => $message, 'time' => $time]);
 }
开发者ID:gogl92,项目名称:yii2-teleduino,代码行数:43,代码来源:ApiController.php

示例14: actionAjaxUpdate

 public function actionAjaxUpdate()
 {
     $model = new Poll();
     // Check if there is an Editable ajax request
     if (isset($_POST['hasEditable'])) {
         $id = Yii::$app->request->post('editableKey');
         $model = $this->findModel($id);
         $model->setScenario('editable');
         $message = '';
         // use Yii's response format to encode output as JSON
         \Yii::$app->response->format = \yii\web\Response::FORMAT_JSON;
         // fetch the first entry in posted data (there should
         // only be one entry anyway in this array for an
         // editable submission)
         // - $posted is the posted data for model without any indexes
         // - $post is the converted array for single model validation
         $post = [];
         $posted = current($_POST[$model->formName()]);
         $post[$model->formName()] = $posted;
         // read your posted model attributes
         if ($model->load($post)) {
             if (!$model->save()) {
                 $errors = \yii\helpers\Html::errorSummary($model);
                 $message .= Yii::t('app/error', 'Poll wasn\'t saved!{errors}', ['errors' => $errors]);
             }
             // custom output to return to be displayed as the editable grid cell
             // data. Normally this is empty - whereby whatever value is edited by
             // in the input by user is updated automatically.
             $output = '';
             return ['output' => $output, 'message' => $message];
         } else {
             // else if nothing to do always return an empty JSON encoded output
             return ['output' => '', 'message' => ''];
         }
     }
 }
开发者ID:EuresTools,项目名称:eVote-web,代码行数:36,代码来源:PollController.php

示例15: renderErrors

 /**
  * Renders validator errors of filter model.
  * @return string the rendering result.
  */
 public function renderErrors()
 {
     if ($this->filterModel instanceof Model && $this->filterModel->hasErrors()) {
         return Html::errorSummary($this->filterModel, $this->filterErrorSummaryOptions);
     } else {
         return '';
     }
 }
开发者ID:sanggabee,项目名称:hellomedia-yii-basic,代码行数:12,代码来源:GridView.php


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