I’m working on a new project, and would like to make it convenient for users
to recover passwords, etc. by auto-filling their username based on the login
form when the click a password recovery link.
My initial solution is formlink.jquery,
as follows:
...
<input id="LoginForm_username" name="LoginForm[username]" />
<a href="passwordRecovery.php" data-formlink="#LoginForm_username" data-replacements='{"LoginForm": "PasswordRecoveryForm"}'>Forgotten your password?</a>
...
[i]Note that I do use Yii-s built-in functionality to create form an links, however, I chose to use plain
HTML in the example to keep things simple.[/i]
In the password recovery action I do the following:
$model = new PasswordRecoveryForm();
if (isset($_POST['PasswordRecoveryForm'])) {
// generate new password
}
else if (isset($_GET['PasswordRecoveryForm'])) {
$model->setAttributes($_GET['PasswordRecoveryForm']);
}
$this->render('passwordRecovery', array('model' => $model));
Is this a good solution? How do other Yii-users handle such scenarios?
I am considering to create a formlink-widget for Yii to make it slightly
cleaner, are there any interest in such an extension?