Virtual Atributes?

Hi

I need to add a field to the activeForm of a class named "Stand" but the thing is that I dont need to store this attribute in the database. Just need this value for creating another record in another table.

The field I need to add to the form is “user_email” but I can’t just add it like this


<?= $form->field($model, 'user_email')->textInput(['maxlength' => true]) ?>

because it throws Unknown Property error which is obvious.

I was wondering if there is a way In which I could add this formField (including the validation which Yii provides with active form) to the model.

I already added the rule to the "Stand" model


[['user_email'], 'required']

but I dont know what else to do and I have not been able to find any documentation about this.

Thanks in advanced!

You just add it as a field/member of the model class:


class Stand extends \yii\db\ActiveForm

{

	public $user_email; // stores users email for use in whatever



And that should be it :)

OMG thanks… I new it was an easy question but …omg I feel so stupid hahaha

Thanks again, I was going crazy