Tuesday, 15 February 2011

php - How to pass the third parameter from the login form to authenticate the user -



php - How to pass the third parameter from the login form to authenticate the user -

hi using 3rd field in login form login form code this

<div class="row"> <?php echo $form->labelex($model,'username'); ?> <?php echo $form->textfield($model,'username'); ?> <?php echo $form->error($model,'username'); ?> </div> <div class="row"> <?php echo $form->labelex($model,'password'); ?> <?php echo $form->passwordfield($model,'password'); ?> <?php echo $form->error($model,'password'); ?> </div> <div class="row"> <?php echo $form->labelex($model,'userrole'); ?> <?php $data = userrole::model()->findall(); echo $form->dropdownlist($model, 'userrole', chtml::listdata($data, 'id', 'usertype')); ?> <?php echo $form->error($model,'userrole'); ?> </div>

here should pass 3rd parameter authenticate user how pass useridentity class. useridentity class defined username, password attributes username , password so, how 3rd 1

the constructor in cuseridentity setter. create next changes pass userole cuseridentity

1) update form (i'm assuming it's loginform?) public $userrole;

then in authenticate method, update phone call useridentity include userrole

$this->_identity=new useridentity($this->username,$this->password, $this->userrole);

then in in useridentity.php file, add together following:

public $userrole; public function __construct($username, $password, $userrole) { $this->username = $username; $this->password = $password; $this->userrole = $userrole; }

you might have tweak little, that's general gist of you'd need pass variable up. create sure update form::rules() array userrole validated.

php yii

No comments:

Post a Comment