msoa
August 15, 2013, 4:17pm
1
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
lalzada
(Lalzadamohmand)
August 15, 2013, 4:51pm
2
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));
msoa
August 15, 2013, 5:15pm
3
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!
alirz23
(Alirz23)
August 15, 2013, 5:15pm
4
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
lalzada
(Lalzadamohmand)
August 15, 2013, 5:19pm
5
msoa:
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!
u simply want to obtain id in actionTest using POST Method and also without Ajax . Right ?
msoa
August 15, 2013, 5:37pm
6
ok. and also want confirmation appears.
lalzada
(Lalzadamohmand)
August 15, 2013, 5:46pm
7
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
}
lalzada
(Lalzadamohmand)
August 15, 2013, 5:49pm
8
msoa
August 16, 2013, 4:19am
9
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?
msoa
August 16, 2013, 4:22am
10
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
}
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 ?
alirz23
(Alirz23)
August 16, 2013, 3:05pm
11
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
msoa
August 17, 2013, 1:41pm
12
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.
JamesBarnsley
(Jamesbarnsleyfreelance)
August 17, 2013, 6:43pm
13
<?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.
msoa
August 18, 2013, 7:02am
14
Know understand. Only if we using links in Form (CForm, CHtml, CActiveForm) element, these capabilities are available.
[b]
Thanks friends for help.[/b]