J
J
JohnDaniels2016-12-23 17:28:07
Yii
JohnDaniels, 2016-12-23 17:28:07

How to replace text in help-block form?

There is a form

<?php $form = ActiveForm::begin([
               'action' => '/feedback',
               'options' => [
                   'class' => 'form-inline',
                   'method' => 'post',
                   'id' => 'orderform'
               ]
           ]);?>
            <?= $form->field($model, 'name')->textInput(['placeholder'=>'Ваше имя'])->label(false) ?>
            <?= $form->field($model, 'email')->textInput(['placeholder'=>'E-mail'])->label(false) ?>
            <?= $form->field($model, 'phone')->textInput(['placeholder'=>'Номер телефона'])->label(false) ?>

           <?= Html::submitButton('проконсультироваться') ?>
           <?php ActiveForm::end(); ?>

validation rules are specified in the model
public function rules()
    {
        return [
            [['name', 'email', 'phone'], 'string', 'max' => 255],
            [['name', 'email', 'phone'], 'required'],
        ];
    }

if the form is not filled out, a help-block appears with the inscription "Fill in 'Name' is required."
So, how can I change this inscription?

Answer the question

In order to leave comments, you need to log in

[[+comments_count]] answer(s)
M
Maxim Fedorov, 2016-12-23
@JohnDaniels

public function rules(){
    return [
        [['name', 'email', 'phone'], 'string', 'max' => 255],
        [['name', 'email', 'phone'], 'required', 'message' => 'Это текст сообщения'],
    ];
}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question