hi i am working on a Dependent Dropdown and I am following this
unfortunately, i encounter the error [color="#FF0000"]“Object of class victim could not be converted to string”[/color]. Please help
here are my _form and my controller code
_form
<?php
$provId = CHtml::activeId($model, 'province_id');
echo CHtml::dropDownList($model,'region_id', $region,
array(
'empty' => '',
'style'=>'background-color:#FFFFFF',
'ajax' => array(
'type'=>'POST',
'url'=>CController::createUrl('dynamicprovinces'),
'update'=> '#'.$provId,
),));
echo $form->dropDownList('province_id','province_id', array(),array('empty' => '', 'class'=>'input input_r', 'style'=>'background-color:#FFFFFF'));
?>
<?php echo $form->error($model,'region_id'); ?>
my controller
public function actionDynamicprovinces()
{
$data=Province::model()->findAll('region_id=:region_id', array(':region_id'=>(int)$_POST['region_id']));
$data=CHtml::listData($data,'id','province_name');
foreach($data as $value=>$name)
{
echo CHtml::tag('option',
array('value'=>$value),CHtml::encode($name),true);
}
}
thank you so much for your help! more power to yii