tags:

views:

2141

answers:

2

Hi, 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?

+2  A: 

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.

mgroves
+1  A: 

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.

Angeline Aarthi