Auto-generate the "required" attribute

The HTML5 "required" attribute is a client-side validation. It enforces the user to fill required fields before form submission, thus reduce server load. In contrast, the CActiveForm allows user to submit form even required fields are not filled.

Is it possible to reflect the required validation rule to the generated HTML, i.e. if a model attribute is required, generate "required" attribute when calling functions like CActiveForm::textField or CHtml::activeTextField()? Thank you!

There’s clientside validation now that does exactly the same as HTML5 attribute. Since HTML5 isn’t supported by all browsers out there, it’s not good to rely on it.