Search code examples
yiiyii-chtml

Yii - CHtml; Difference between active form input and normal form input


Quite simply, what is the difference between using CHtml::textField or CHtml::activeTextField, as well as other Yii CHtml form inputs.

When is it appropriate to use active vs normal form inputs.


Solution

  • The non-active versions are used without a model reference. The active versions all take a model instance as their first argument.

    By having a model instance tied to the form each field has the model's definition, its labels, validation routines tied to the form. It also will be pre-populate fields when updating data.