Yii Framework Forum: Confirm And Submit Options Of Chtml::link [Solved] - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Confirm And Submit Options Of Chtml::link [Solved] Rate Topic: -----

#1 User is offline   msoa 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 238
  • Joined: 15-August 12

Posted 15 August 2013 - 11:17 AM

Hi friends,
In the following code,the confirmation dose not appear(when clicking on the link) 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
0

#2 User is offline   Lal Zada 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 125
  • Joined: 06-November 12
  • Location:Lahore, Pakistan

Posted 15 August 2013 - 11:51 AM

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));

 

Is it fast? Is it secure? Is it professional? Is it right for my next project? Yes, it is

Linkedin Facebook Twitter Google+
0

#3 User is offline   msoa 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 238
  • Joined: 15-August 12

Posted 15 August 2013 - 12:15 PM

View PostLal Zada, on 15 August 2013 - 11:51 AM, said:

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!
0

#4 User is offline   alirz23 

  • Master Member
  • PipPipPipPip
  • Yii
  • Group: Members
  • Posts: 668
  • Joined: 08-August 12
  • Location:Durban, South Africa

Posted 15 August 2013 - 12:15 PM

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
0

#5 User is offline   Lal Zada 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 125
  • Joined: 06-November 12
  • Location:Lahore, Pakistan

Posted 15 August 2013 - 12:19 PM

View Postmsoa, on 15 August 2013 - 12:15 PM, said:

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 ?
Is it fast? Is it secure? Is it professional? Is it right for my next project? Yes, it is

Linkedin Facebook Twitter Google+
0

#6 User is offline   msoa 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 238
  • Joined: 15-August 12

Posted 15 August 2013 - 12:37 PM

View PostLal Zada, on 15 August 2013 - 12:19 PM, said:

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

ok. and also want confirmation appears.
0

#7 User is offline   Lal Zada 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 125
  • Joined: 06-November 12
  • Location:Lahore, Pakistan

Posted 15 August 2013 - 12:46 PM

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
	}


Is it fast? Is it secure? Is it professional? Is it right for my next project? Yes, it is

Linkedin Facebook Twitter Google+
0

#8 User is offline   Lal Zada 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 125
  • Joined: 06-November 12
  • Location:Lahore, Pakistan

Posted 15 August 2013 - 12:49 PM

read example #9 and #10

http://www.yiiframew...mple-chtml/#hh0
Is it fast? Is it secure? Is it professional? Is it right for my next project? Yes, it is

Linkedin Facebook Twitter Google+
0

#9 User is offline   msoa 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 238
  • Joined: 15-August 12

Posted 15 August 2013 - 11:19 PM

View PostLal Zada, on 15 August 2013 - 12:49 PM, said:


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?
0

#10 User is offline   msoa 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 238
  • Joined: 15-August 12

Posted 15 August 2013 - 11:22 PM

View PostLal Zada, on 15 August 2013 - 12:46 PM, said:

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?
0

#11 User is offline   alirz23 

  • Master Member
  • PipPipPipPip
  • Yii
  • Group: Members
  • Posts: 668
  • Joined: 08-August 12
  • Location:Durban, South Africa

Posted 16 August 2013 - 10:05 AM

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
1

#12 User is offline   msoa 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 238
  • Joined: 15-August 12

Posted 17 August 2013 - 08:41 AM

View Postalirz23, on 16 August 2013 - 10:05 AM, said:

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:
0

#13 User is offline   JamesBarnsley 

  • Advanced Member
  • PipPipPip
  • Yii
  • Group: Members
  • Posts: 414
  • Joined: 18-November 10
  • Location:UK

Posted 17 August 2013 - 01:43 PM

View Postmsoa, on 17 August 2013 - 08:41 AM, said:

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.
1

#14 User is offline   msoa 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 238
  • Joined: 15-August 12

Posted 18 August 2013 - 02:02 AM

View Postalirz23, on 16 August 2013 - 10:05 AM, said:

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

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

Thanks friends for help.

0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users