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?