Yii Framework Forum: $_Post Data Not Available From Controller - Yii Framework Forum

Jump to content

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

$_Post Data Not Available From Controller Cannot acces $_POST['Sipconf[template_id]'] Rate Topic: -----

#1 User is offline   hmsdexter 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 12
  • Joined: 07-May 12

Posted 24 April 2013 - 08:37 AM

I have the following view and controller files:

View:
		<?php 
		 echo $form->dropDownList($model,'template_id',CHTML::listData(Sipconf::model()->findAllByAttributes(array('istemplate'=>'1')),'client_id','name'),
		 array(
			 'ajax' => array(
			 	'type' => 'post',
			 	'dataType' => 'json',
			 	'url'=> CController::createUrl('sipconf/loadtemplate'),			 	
			 	'success'=>'function(data){
			 	$("#Sipconf_extension").val(data.extension);
				$("#'.CHTML::activeId($model,'name').'").val(data.name);
			 	$("#'.CHTML::activeId($model,'number').'").val(data.number);
				}'
			 	 
				)
			 )
		 ); 
		 
		
		?>



Controller:
	public function actionLoadTemplate(){
		$templateid=$_POST['Sipconf[template_id]'];

		 echo CJSON::encode(
		 array(
	            'extension'=> $templateid,
	            'name'=>"Demo name",
	            'number'=>"0123456789"
	           
	            )
	);


the line
$templateid=$_POST['Sipconf[template_id]'];

does not return the value of Sipconf[template_id]

firebug shows that the following data is being sent to the controller via post:
Sipconf[accountcode]	
Sipconf[canreinvite]	0
Sipconf[context]	NULL
Sipconf[dtmfmode]	1
Sipconf[extension]	
Sipconf[hasvoicemail]	0
Sipconf[host]	dynamic
Sipconf[istemplate]	0
Sipconf[jbforce]	0
Sipconf[jbmaxsize]	300
Sipconf[mac]	
Sipconf[name]	Demo name
Sipconf[number]	0123456789
Sipconf[qualify]	0
Sipconf[secret]	mysecret
Sipconf[template_id]	3
Sipconf[type]	1


with the source show as:
Sipconf%5Btemplate_id%5D=3&Sipconf%5Bextension%5D=&Sipconf%5Bname%5D=Demo+name&Sipconf%5Baccountcode%5D=&Sipconf%5Bnumber%5D=0123456789&Sipconf%5Btype%5D=1&Sipconf%5Bcontext%5D=NULL&Sipconf%5Bhost%5D=dynamic&Sipconf%5Bcanreinvite%5D=0&Sipconf%5Bsecret%5D=mysecret&Sipconf%5Bdtmfmode%5D=1&Sipconf%5Bqualify%5D=0&Sipconf%5Bjbmaxsize%5D=300&Sipconf%5Bjbforce%5D=0&Sipconf%5Bmac%5D=&Sipconf%5Bhasvoicemail%5D=0&Sipconf%5Bistemplate%5D=0


any advice?
0

#2 User is offline   Keith 

  • Elite Member
  • Yii
  • Group: Moderators
  • Posts: 1,502
  • Joined: 04-March 10
  • Location:UK

Posted 24 April 2013 - 08:39 AM

PHP has already converted it to an array for you:

$templateid=$_POST['Sipconf']['template_id'];

0

#3 User is offline   hmsdexter 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 12
  • Joined: 07-May 12

Posted 24 April 2013 - 08:44 AM

View PostKeith, on 24 April 2013 - 08:39 AM, said:

PHP has already converted it to an array for you:

$templateid=$_POST['Sipconf']['template_id'];



Too right, I fell i should have been able to figure that one out.
Thank you
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