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


PHP Html::errorSummary方法代码示例

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


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

示例1: actionIndex

 /**
  * Привязка дисконтной карты
  */
 public function actionIndex()
 {
     Yii::$app->response->format = Response::FORMAT_JSON;
     $model = new DiscountCardForm();
     if (Yii::$app->request->isAjax && $model->load(Yii::$app->request->post())) {
         if (!$model->validate()) {
             return ['result' => false, 'message' => Html::errorSummary($model, ['header' => false, 'class' => 'alert alert-danger'])];
         }
         $userCard = new UserCard();
         $userCard->card = $model->fullName;
         $result = $userCard->getInfo();
         /** @var \novatorgroup\usercard\Module $module */
         $module = Yii::$app->getModule('card');
         if (isset($result->type)) {
             $module->afterCheckCard($model);
             return ['result' => true];
         } else {
             $module->errorCheckCard($model, $result->error);
             return ['result' => false, 'message' => Html::tag('div', $result->error, ['class' => 'alert alert-danger'])];
         }
     }
     return ['result' => false, 'message' => 'Ошибка привязки карты'];
 }
开发者ID:novatorgroup,项目名称:user-card-module,代码行数:26,代码来源:DefaultController.php

示例2: mergeRelation

 /**
  * @param bool|false $delete если удаляется оснавная модель
  * @throws Exception
  * @throws \yii\base\InvalidConfigException
  */
 public function mergeRelation($delete = false)
 {
     foreach ($this->relations as $relation) {
         $this->relationModels[$relation] = [];
         $modelDelete = [];
         $modelSave = [];
         if ($delete && $this->owner->{$relation}) {
             $modelDelete = $this->owner->{$relation};
             // обновляем релейшин, если в CurrentValue он явно задан
         } elseif (key_exists($relation, $this->relationNewValue) && is_array($this->relationNewValue[$relation])) {
             // находим имя PK
             $getter = 'get' . $relation;
             /** @var ActiveRecord $modelClass */
             $modelClass = $this->owner->{$getter}()->modelClass;
             $pk = $modelClass::primaryKey();
             if (!isset($pk[0])) {
                 throw new Exception('Ключ не задан');
             }
             foreach ($this->relationNewValue[$relation] as $key => $values) {
                 $model = null;
                 $arrayPk = [];
                 foreach ($pk as $field) {
                     $arrayPk[$field] = isset($values[$field]) ? $values[$field] : null;
                 }
                 $model = $modelClass::findOne([$arrayPk]);
                 if ($model && isset($this->scenarios[$relation]['update'])) {
                     $model->scenario = $this->scenarios[$relation]['update'];
                 }
                 if (!$model) {
                     $config = [];
                     if (method_exists($modelClass, 'setFormName')) {
                         $config = ['formName' => $key];
                     }
                     $model = new $modelClass($config);
                     $model->scenario = ArrayHelper::getValue($this->scenarios, $relation . '.create', Model::SCENARIO_DEFAULT);
                 }
                 /** @var ActiveRecord $model */
                 $model->setAttributes(array_merge($this->getRelationFk($relation), $values));
                 $modelSave[] = $model;
             }
             // если не только добавление, но и удаление связанной модели, то сверяем:
             if (!$this->onlyAdd && $this->owner->{$relation}) {
                 foreach ($this->owner->{$relation} as $oldModel) {
                     $found = false;
                     /** @var ActiveRecord $newModel */
                     foreach ($modelSave as $newKey => $newModel) {
                         if ($oldModel->primaryKey == $newModel->primaryKey) {
                             $found = true;
                             break;
                         }
                     }
                     // Если запись в текущих данных нет, значит ее нужно удалить.
                     if (!$found) {
                         $modelDelete[] = $oldModel;
                     }
                 }
             }
         }
         /** @var ActiveRecord $model */
         foreach ($modelDelete as $model) {
             if (!$model->delete()) {
                 $this->errors[$relation][] = strip_tags(Html::errorSummary($model));
             }
             $this->relationModels[$relation][] = $model;
         }
         /** @var ActiveRecord $model */
         foreach ($modelSave as $model) {
             if (!$model->save()) {
                 $this->errors[$relation][] = strip_tags(Html::errorSummary($model));
             }
             $this->relationModels[$relation][] = $model;
         }
     }
 }
开发者ID:dd174,项目名称:yii2-related-behavior,代码行数:79,代码来源:RelatedBehavior.php

示例3:

                            <div class="col-lg-4">
                                <?php 
echo \Yii::t('app', 'SENSOR ADMIN MAIL');
?>
                                <br /><?php 
echo \Yii::t('app', 'Who will be uploading data?');
?>
                            </div>  
                            <div class="col-lg-8">
                                <?php 
echo Html::activeInput('text', $model, 'admin_email');
?>
                            </div>  
                            <div class="col-lg-12 text-center">
                                <?php 
echo Html::errorSummary($model);
?>

                                <?php 
echo Html::submitButton('<span class="glyphicon glyphicon-check"></span> ' . ($model->isNewRecord ? \Yii::t('app', 'Create sensor') : \Yii::t('app', 'Save sensor')), ['id' => 'save-' . $model->formName(), 'class' => 'btn btn-danger']);
?>
                            </div>  
                            <div class="col-lg-12">
                                <br /><br /><br />
                            </div>  
                        </div>
                        <?php 
Html::endForm();
?>
                        <br /><br /><br />
                    </div>
开发者ID:ICHydro,项目名称:anaconda,代码行数:31,代码来源:addsensor.php


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