Reputation: 4059
I am a newbie in Yii. I have created a page where user can change their password.
So in my changePassword view I have :
<div class="row">
<?php echo $form->labelEx($model,'oldpwd'); ?>
<?php echo $form->textField($model,'oldpwd'); ?>
<?php echo $form->error($model,'oldpwd'); ?>
</div>
<div class="row">
<?php echo $form->labelEx($model,'pwd'); ?>
<?php echo $form->textField($model,'pwd'); ?>
<?php echo $form->error($model,'pwd'); ?>
</div>
<div class="row">
<?php echo $form->labelEx($model,'pwd_repeat'); ?>
<?php echo $form->passwordField($model,'pwd_repeat'); ?>
<?php echo $form->error($model,'pwd_repeat'); ?>
</div>
Now obviously I am getting an error as only the field 'pwd' is in the table and thereby in the model. I am new to MVC frameworks and can use some help here. Thanks
Upvotes: 1
Views: 1643
Reputation: 3024
add the following line to your model
public $old_pwd;
public $pwd_repeat;
we instruct Yii to use this field as virtual field instead of searching in database field
Upvotes: 0
Reputation: 11264
Declare them in your model as property of model First..
public $old_pwd;
public $pwd;
public $pwd_repeat;
As you are asking model Labels of these attributes..define them in your attributeLabels function in model..
public function attributeLabels()
{
return array(
'old_pwd'=>'Old Passw....',
'.....same way for all those who are not already there..'
);
}
Declare them safe in rules if required...
Upvotes: 2