本文整理汇总了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' => 'Ошибка привязки карты'];
}
示例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;
}
}
}
示例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>