email confirmation

I want the user to create an account with the following parameter:

manager_name, manager_email and manager_phone. However, I want the user to confirm the email (with manager_email_confirm) using another textinput, in case there is a mistake. But am having an error.

MODEL

public function rules()

{


    return [


        [['manager_name', 'manager_unique_id','manager_email', 'manager_phone'],'required'],


        [['manager_email'],'email', 'message'=>"The email isn't correct"],


        ['manager_email','filter', 'filter' => 'trim'],


        [['manager_email_confirm'],'required', 'on'=>'register'],


        [['manager_name','manager_phone'],'string'],


        [['manager_email', 'compare', 'compareAttribute'=>'manager_email_confirm'],'message'=>'Email mismatch. Please confirm...', 'on' => 'register'],        


    ];


}





/**


 * @inheritdoc


 */


public function attributeLabels()


{


    return [


        'Maneger_id' => Yii::t('consumers', 'Manager ID'),


        'manager_unique_id' => 'Manager Unique ID',


        'Manager_name' => Yii::t('consumers', 'Manager Name'),


        'manager_user_id' => 'Building Manager User ID',


        'manager_email' => Yii::t('consumers', 'Manager Email'),


        'manager_email_confirm' => Yii::t('consumers', 'Confirm Email'),


        'manager_phone' => Yii::t('consumers', 'Manager Phone'),


        


    ];


}

VIEW

<div class="col-xs-12 col-sm-12 col-lg-12">

<?= $form->field($model, ‘manager_name’)->textInput([‘placeholder’=>‘Enter Building Manager Name’]) ?>

</div>

<div class="col-xs-12 col-sm-12 col-lg-12">

<?= $form->field($model, ‘manager_phone’)->textInput([‘placeholder’=>‘Enter Building Manager Phone’]) ?>

</div>

<div class="col-xs-12 col-sm-12 col-lg-12">

<?= $form->field($model, ‘manager_email’)->textInput([‘placeholder’=>‘Enter Building Manager Email’]) ?>

</div>

<div class="col-xs-12 col-sm-12 col-lg-12">

<?= $form->field($model, ‘manager_email_confirm’)->textInput([‘placeholder’=>‘Confirm Building Manager Email’]) ?>

</div>

ERROR

Exception (Invalid Configuration) ‘yii\base\InvalidConfigException’ with message ‘Invalid validation rule: a rule must specify both attribute names and validator type.’ 7010

ERROR.PNG

Try this:




[['manager_email'], 'compare', 'compareAttribute'=>'manager_email_confirm','message'=>'Email mismatch. Please confirm...', 'on' => 'register'], 



Please use "code" tags when posting code.

I tried it as you suggested. See the new error below:

Getting unknown property: app\modules\consumers\models\BuildingManager::manager_email_confirm

7011

email error.PNG

Well… what do you think the error message is trying to tell you?

It cant find it in the model and the table. It should not be in the table, since its just to confirm that the email address is correct before saving it

Try adding it as a property to your model then:


public $manager_email_confirm;

It works.

Thanks a lot