Question

I know that the code to get a confirm message while clicking on a link is as given below.

<?php 
     echo $html->link('Delete',
            array('controller'=>'forms','action'=>'delete', $r['Form']['id']),
            array(),
            'really delete the Form ?',
            false
            );
        ?>

I need an alert box saying "Your form has been deleted" after deleting the form by clicking on the 'ok' button in the confirm message.

Is there a method to get an alert box instead of the confirm box or an alert box after the confirm box?

Was it helpful?

Solution

I found out the answer which uses the Ajax helper. It is all in the cake book, I just need to read it more carefully. Instead of using $html->link,need to use $ajax->link Here is the code to get the alert box in the html link.

<?php
      echo $ajax->link('Publish',
     array('controller'=>'forms','action'=>'publish', $formid),
      array('update'=>'view','complete'=>'alert("Your form has been published")')
      'Are you sure?',false);
?>

The alert box is called after the action is completed and should be mentioned in the 'complete' condition of the $ajax->link array.

OTHER TIPS

You'll need to use JavaScript to do this. A click event would fire and in that event, you would call "alert("hey!");" This is really independent of the CakePHP framework, as I don't think there's a JavaScript helper to do that.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top