Hello everyone!
I have some code:
public function actionVchytel2()
{
$v2 = $_POST['vchhotid'];
$vch_hot = JosPpnz::model()->findByPk($v2);
$vch_hot_ol = new Vch2;
$vch_hot_ol->prizv=$vch_hot->getAttribute('name');
$vch_hot_ol->robota=$vch_hot->getAttribute('schoolid');
$vch_hot_ol->posada=$vch_hot->getAttribute('posada');
$vch_hot_ol->ppnz_id=$v2;
$vch_hot_ol->save();
echo $vch_hot_ol->getPrimaryKey();
}
This is my controller’s action which is activated by this ajax request:
<?php echo CHtml::dropDownList('v2','', array(), array('empty' => '','class'=>'input input_r',
'style'=>'background-color:#FFFFFF',
'ajax' => array(
'type'=>'POST',
'dataType'=>'text',
'url'=>CController::createUrl('site/vchytel2'),
'data'=>array('vchhotid'=>'js:$(this).val()'),
'success'=>'js:function(data){
$("#vch_hot").val(data);
}',),
));?>
The problem is that the action does not return the expected primary key.
Any suggestions?
Thank you.