Confirm And Submit Options Of Chtml::link [Solved]

Hi friends,

In the following code,the confirmation dose not appear([size="1"]when clicking on the link[/size]) and also var_dump($_POST) is null !




public function actionTest()

{

	<?php

    	echo CHtml::link('Test',"test", array("submit"=>array('test', 'id'=>$data->ID), 'confirm' => 'Are you sure?', 'csrf'=>true)); 

	?>

}



I don’t understand what’s usage of submit and confirm options!? Do these are available in Ajax method and don’t work in traditional POST method?

Thanks

What are u trying to do with this function ?

in below code, confirmation appears onclick





echo CHtml::link('Test',"test", array("submit"=>array('test', 'id'=>$data->ID), 'confirm' => 'Are you sure?', 'csrf'=>true));


 

It’s clear, i want when clicking on the link appears an confirmation and can obtain id in actionTest. I don’t use from Ajax. Do these functionalitise are available on non-ajax requests? traditional post.

In your code also don’t appear confirmation and don’t set $_POST variable!

the confirm usually used for delete links for verification, you could click On delete by mistake

EDIT:

as far as link is concerned

CHtml::link remove the php tags

u simply want to obtain id in actionTest using POST Method and also without Ajax . Right ?

ok. and also want confirmation appears.

If U want to pass value of id to actionTest in controller : Simply like this

View.php





echo CHtml::link('Test',"test", array("submit"=>array('view', 'id'=>$data->id), 'confirm' => 'Are you sure?', 'csrf'=>true));




Controller.php





public function actionTest($id)

	{

        	// u can use $id here

	}




read example #9 and #10

http://www.yiiframework.com/wiki/48/by-example-chtml/#hh0

I was reading this wiki, exactly #9 and #10. in these number writer mentioned Linking to a controller action via POST with POST parameters, what’s mean from post parameters? and also confirmation what when appears?

I know how pass data as $_GET.

here in #9 and #10 mentioned: Linking to a controller action via POST with POST parameters, what’s mean POST parameters?

when it says POST it uses form instead of old plain link you can think of POST parameters as form fields that you can send it along

I don’t understand your mean! I just now the only way for sending POST data to server in PHP is using FORM, and also manipulating HTTP headers.

:blink:




<?php echo CHtml::link('Test',"test", array("submit"=>array('test', 'id'=>$data->ID), 'csrf'=>true), array("onclick" => "return confirm('Are you sure?');")); ?>



Try that if your confirm is not working.

Know understand. Only if we using links in Form(CForm, CHtml, CActiveForm) element, these capabilities are available. :)

[b]

Thanks friends for help.[/b]