I’m very new to PHP frameworks, so this might be a simple question.
I have a [font="Courier New"]User[/font] model class which has a [font="Courier New"]password2[/font] virtual attribute so that [font="Courier New"]password[/font] can be verified against [font="Courier New"]password2[/font].
class Usager extends \yii\db\ActiveRecord
{
public $password2;
}
When I call [font="Courier New"]$model->load()[/font], it does not populate the [font="Courier New"]password2[/font] attribute. It is in [font="Courier New"]$request->post()[/font]. The only way I found was to do it manually like this, but I feel this is not the best solution.
$model->load($request->post());
$model->password2 = $request->post($model->formName())['password2'];
I also have the same situation in a [font="Courier New"]UserSearch[/font] model class where I have a [font="Courier New"]keyword[/font] attribute that searches in [font="Courier New"]firstName[/font] and [font="Courier New"]lastName[/font] columns in the database.
What is the proper way to do this?