Thursday, April 21, 2011

Display Confirm Message before a Custom Object Action with Admin Generator in Symfony

        object_actions:
          _edit: ~
          send: { params: { onclick : "if(confirm('Are you sure?')){return true;}else{return false;}" } }

6 comments:

  1. This not works with a defaul action like _delete

    ReplyDelete
  2. Yes, _delete has a 'confirm' parameter. You can change the confirm text with it:

    _delete: { label: Delete, confirm: Are you sure? }

    ReplyDelete
  3. That just saved my day :-)

    Many thanks!

    ReplyDelete
  4. THANKS!!!!!!!!!!!! :D :D :D :D

    ReplyDelete
  5. what if I use a prompt and I want to pass it to the called action ?

    ReplyDelete
    Replies
    1. Hmm. In this case, I would add a class name (ex promptbutton) to the action button then put a 'click' event on the class name with jquery ( $('.promptbutton').click(...) ), and append the this.href value with the prompt value. I hope this helps.

      Delete