Yii Active Field Form



  • Good night. There is a form:

    <?php $form = ActiveForm::begin([
                    'id' => 'login-form',
                ]); ?>
    

    <?= $form->field($model, 'username', ['options'=>['class'=>'asd']])
    ->error(false)
    ->label(false) ?>

    <?= $form->field($model, 'password')
    ->passwordInput()
    ->error(false)
    ->label(false) ?>

    <?= Html::submitButton('Login', ['class' => 'btn btn-primary', 'name' => 'login-button']) ?>

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

    In default, when an indicator is placed on the field, it is illuminated.
    Also, when data are sent (in case of failure) the same shall be illuminated.
    How do you get that?
    Just rewrite the style?

    <div class="form-group field-loginform-password required has-error">

      &lt;input type="password" id="loginform-password" class="form-control" name="LoginForm[password]" value="nbv"&gt;
    

    </div>

    Yes, and in fact, if I want some form of input, I can certainly write the styles on them. But is it right to rewrite the existing ones to the light?



  • <?php $form = ActiveForm::begin([
        'id' => 'login-form',
        'enableClientValidation'=> false, 
        'enableAjaxValidation' => false,
    ]); ?>
    

    enableClientValidation - responsible for validating the form on the client with JavaScript

    enableAjaxValidation - is responsible for validating the form on the server through AJAX, also without overloading the page.


Log in to reply
 


Suggested Topics

  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2