I’m working on my second Yii application and I must say it is quite a high learning curve. (I’m still fairly new)
I don’t know if this is possible but can I accept a custom attribute in a form that is not in my DB as a field.
This model (Orders) have a user_name and user_email field.
I basically want a drop down of another model (Users) to look up and save the name and email once the form has been validated to the Orders model.
The reasoning why i don’t want a relation between the two tables is if a user is deleted I still want to retain the user’s name and email on the order.
When I try and add a drop down with any kind of id on my _form I start getting errors. Not defined.
Well to create a non db attribute in model class you can define public variable in your model class and define them in your model rules also for validation purpose then you can access that attributes too in your form.
public $customAttr;
And in rule section
array(
'customAttr','required' //you can change it according to your need
),
And now you can use like $model->customAttr;