Why forms for DB and non-DB models are differently styled?

Both login form and some Gii-generated model’s create form are using yii\widgets\ActiveForm:

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

But the resulting forms are completely differently styled:

dgds

Key differences that I have spotted:

  1. Validation errors are styled using class="help-block" in DB model’s forms and with class="invalid-feedback in case of login form (non-DB model’s form).
  2. Login form has special styling for fields that are passing and are not passing validation (green and red border). DB-model form has no border at all.
  3. There’s a padding / margin between label and field in login form that is missing in model form.
  4. Submit button has a padding / margin above (between it and the previous field) in login form while in model form it is directly “glued” to the last field.
  5. Etc., etc.

Why is that? Where’s the magic that controls that? What changes or steps must I undertake to have all my model’s forms styled in exactly the same way as I have my login form styled?

I have some suspicion. Verify what version of ActiveForm, from which namespace you are using and where:
yii\widgets
yii\bootstrap
yii\bootstrap5

1 Like

Bingo!

use yii\bootstrap5\ActiveForm;

vs.:

use yii\widgets\ActiveForm;

Thank you for pointing out something that should be obvious to me! :[