Reputation: 2660
I wish to build a form that does not create/update any active records. An example of such a form would be a search filter using check boxes for the user to select which categories to apply to the search.
Everything I read about forms in Yii is centred around the CActiveForm class. What is the Yii way to build forms that don't use active records?
Upvotes: 2
Views: 442
Reputation: 8607
If you want to embrace Yii's convenient form handling, you should use CActiveForm
. It does not require CActiveRecord
. But it always requires a model for your form data - which is a good thing, because this will keep the validation rules out of your view files. Instead of a CActiveRecord
you could also build a simple model class from CFormModel
.
class SomeForm extends CFormModel
{
public $name;
public $email;
public function rules()
{
return array(
array('name,email','required'),
array('email','email'),
);
}
}
Upvotes: 2
Reputation: 6356
Check the docs of the CHtml class. While it contains all the active* method, there are plain form methods in there as well, such as checkBox() or checkBoxList() that sound like what you're looking for.
Upvotes: 1