Reputation: 341
my system (built in Yii 1.1.19), I have several instances where I delete a record, and I have a confirm request to bring an alert before it continues to delete - all works fine, see below;
$this->menu = array(
array('label' => 'Delete User', 'url' => '#', 'linkOptions' => array('submit' => array('delete', 'id' => $model->id), 'confirm' => "Are you sure you want to delete this user?",
'params' => array(Yii::app()->getRequest()->csrfTokenName => Yii::app()->getRequest()->csrfToken))),
);
Pretty standard Yii - however, I want the user to confirm their password before they delete specific records, as an extra security measure. Not necessarily within its own user model either, i.e. I might want to check the user's password before I delete a specific setting from a different model.
I understand what I need to do once I have an input - how to check the existing password, but I can't figure out how to actually alter the confirm to get the input form instead of standard confirm.
Can anyone help? Sounds like a straightforward request, but I can't seem to much online
Upvotes: 0
Views: 138
Reputation: 39
Have you tried using "prompt" instead of confirm? or using a JS function and then calling prompt? https://www.w3schools.com/jsref/met_win_prompt.asp
That should allow you to get an input for the password. However, i don't think that's the best way since passwords are expected to be masked (prompt doesn't mask the input) so, what i would propose instead is to use an ajax loaded html form (could be modal) so you could properly handle the the password
Upvotes: 1