Creating Forms ============== The primary way of using forms in Yii is through [[yii\widgets\ActiveForm]]. This approach should be preferred when the form is based upon a model. Additionally, there are some useful methods in [[yii\helpers\Html]] that are typically used for adding buttons and help text to any form. A form, that is displayed on the client side, will in most cases have a corresponding [model](structure-models.md) which is used to validate its input on the server side (Check the [Validating Input](input-validation.md) section for more details on validation). When creating model-based forms, the first step is to define the model itself. The model can be either based upon an [Active Record](db-active-record.md) class, representing some data from the database, or a generic Model class (extending from [[yii\base\Model]]) to capture arbitrary input, for example a login form. In the following example we show, how a generic Model is used for a login form: ```php 'login-form', 'options' => ['class' => 'form-horizontal'], ]) ?> = $form->field($model, 'username') ?> = $form->field($model, 'password')->passwordInput() ?>