Confirmation Message In Action

Hi guys

Just wondering if it is possible to call a confirmation message in a controller action?

I know that you can do this:

<?php echo CHtml::submitButton($model->isNewRecord ? 'Create' : 'Save',

    array('confirm'=> 'Are you Sure')); ?>

However in my app, the user selects from a dropdown and then clicks the submit button. The dropdown list contains a list of states and the action has to compare the selected state against the current state, so the confirmation message should change depending on the state.

Lets says the current state is “Application Received” (which would also be the selected option in the dropdown list), the user could select “Application Approved”, which means that lots of other things will be updated. So I want the user to be sure of what they are doing. Clicking ‘Confirm’ on the dialog should update the current state to the selected state and whatever else needs to be done.

I just need to know how to get that dialog to appear when the action is called.

If you need any code, just let me know.

Any help would be great!

I found a workaround using sessions and setting TbModal to autoOpen.

So basically what I am doing now is calling my action with a parameter of "$confirm=true".

As $confirm is true, a session variable is set and the initial page is reloaded, rendering the modal dialog. This is related to an earlier question I had (TbButton and TbModal) where I have my view checking if the session is set. If it is, the modal dialog is rendered, which I wanted to avoid.

In the modal dialog, if the user clicks the Confirm button, the action is called again but with $confirm=false and the rest of the action can be executed.

So it’s working fine now but I’d be really interested in hearing some other opinions on how to do this.