Reputation: 2060
Is there a way to automate validation in Yii if the fields of a model are rows in a table instead of columns? The form is generated at runtime and there is a table just for the elements of the form.
Upvotes: 0
Views: 75
Reputation: 31397
On your model, you can define has many properties as you wish.
By doing that, you can then call those properties on your rules()
model *method*.
Something like:
public $myproperty;
public function rules()
{
return array(
array('myproperty', 'required', 'message'=>'This field is REALLY required')
),
Then, on your view if, for example, you use CActiveForm, you can:
$form->error($yourModelNameHere, 'myproperty');
Upvotes: 1