errorSummary() public static method

If there is no validation error, an empty error summary markup will still be generated, but it will be hidden.
public static errorSummary ( Model | Model[] $models, array $options = [] ) : string
$models yii\base\Model | yii\base\Model[] the model(s) whose validation errors are to be displayed.
$options array the tag options in terms of name-value pairs. The following options are specially handled: - header: string, the header HTML for the error summary. If not set, a default prompt string will be used. - footer: string, the footer HTML for the error summary. Defaults to empty string. - encode: boolean, if set to false then the error messages won't be encoded. Defaults to `true`. - showAllErrors: boolean, if set to true every error message for each attribute will be shown otherwise only the first error message for each attribute will be shown. Defaults to `false`. Option is available since 2.0.10. The rest of the options will be rendered as the attributes of the container tag.
return string the generated error summary
Beispiel #1
0
echo $form->field($model, 'rec_status_id')->radioList(ArrayHelper::map(\app\models\RecStatus::find()->active()->all(), 'id', 'name'), ['class' => 'btn-group', 'data-toggle' => 'buttons', 'unselect' => null, 'item' => function ($index, $label, $name, $checked, $value) {
    return '<label class="btn btn-default' . ($checked ? ' active' : '') . '">' . Html::radio($name, $checked, ['value' => $value, 'class' => 'project-status-btn']) . $label . '</label>';
}]);
?>

    <?php 
echo $form->field($model, 'user_id')->dropDownList(ArrayHelper::map(\app\models\User::find()->active()->all(), 'id', 'name'), ['prompt' => '']);
?>

    <?php 
echo $form->field($model, 'dc')->textInput();
?>

    <div class="form-group">
        <div class="col-lg-offset-2 col-lg-10">
            <?php 
echo Html::submitButton($model->isNewRecord ? Yii::t('app', 'Save') : Yii::t('app', 'Update'), ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']);
?>
        </div>
    </div>

    <?php 
ActiveForm::end();
?>

</div>

<?php 
if ($model->hasErrors()) {
    echo \kartik\growl\Growl::widget(['type' => \kartik\growl\Growl::TYPE_DANGER, 'title' => 'Необходимо исправить следующие ошибки:', 'icon' => 'glyphicon glyphicon-exclamation-sign', 'body' => \yii\helpers\BaseHtml::errorSummary($model, ['header' => '']), 'showSeparator' => true, 'delay' => 10, 'pluginOptions' => ['placement' => ['from' => 'top', 'align' => 'right']]]);
}
Beispiel #2
0
$other_errors = '';
//echo print_r($model->errors);
if ($model->hasErrors()) {
    echo \kartik\growl\Growl::widget(['type' => \kartik\growl\Growl::TYPE_DANGER, 'title' => 'Ошибки в резюме:', 'icon' => 'glyphicon glyphicon-exclamation-sign', 'body' => \yii\helpers\BaseHtml::errorSummary($model, ['header' => '']), 'showSeparator' => true, 'delay' => 100, 'pluginOptions' => ['placement' => ['from' => 'top', 'align' => 'right']]]);
    $main_err = $model->hasErrors('salary') + 0;
    $model_errors = $main_err ? ' <span title="Количество ошибок" style="margin-left: 10px;" class="label label-danger pull-right" > ' . $main_err . '</span>' : '';
    $other_errors = count($model->errors) > $main_err ? ' <span title="Количество ошибок" style="margin-left: 10px;" class="label label-danger pull-right" > ' . (count($model->errors) - $main_err) . '</span>' : '';
    if ($active_tab == 0 && $main_err > 0) {
        $active_tab = 1;
    }
    if ($active_tab == 0 && count($model->errors) > $main_err) {
        $active_tab = 2;
    }
}
if ($person->hasErrors() || $person_address->hasErrors()) {
    echo \kartik\growl\Growl::widget(['type' => \kartik\growl\Growl::TYPE_DANGER, 'title' => 'Ошибки в личных данных соискателя:', 'icon' => 'glyphicon glyphicon-exclamation-sign', 'body' => \yii\helpers\BaseHtml::errorSummary($person, ['header' => '']) . \yii\helpers\BaseHtml::errorSummary($person_address, ['header' => '']), 'showSeparator' => true, 'delay' => 1100, 'pluginOptions' => ['placement' => ['from' => 'top', 'align' => 'right']]]);
    $person_errors = count($person->errors) || count($person_address->errors) ? ' <span title="Количество ошибок" style="margin-left: 10px;" class="label label-danger pull-right" > ' . (count($person->errors) + count($person_address->errors)) . '</span>' : '';
    if ($active_tab != 1) {
        $active_tab = 3;
    }
}
?>

<div class="resume-form">

<?php 
$form = ActiveForm::begin(['enableClientValidation' => true, 'validateOnSubmit' => false, 'options' => ['class' => 'form-horizontal'], 'fieldConfig' => ['template' => "{label}\n<div class=\"col-lg-4\">{input}</div>\n<div class=\"col-lg-6\">{error}</div>", 'labelOptions' => ['class' => 'col-lg-2 control-label']]]);
?>

<?php 
$this->beginBlock('main');