Hi People.
I’m a noob in Yii, so i’m learning it yet.
I’m using the method CActiveForm::dropDownList() and having a problem to load data in the dropdownList.
In this function i get the data.
public function actionCreate()
{
$model=new Cidades;
$mestados = new Estados();
$estados = $mestados->getAllEstado()->queryAll();
#var_dump($estados);exit;
// Uncomment the following line if AJAX validation is needed
// $this->performAjaxValidation($model);
if(isset($_POST['Cidades']))
{
$model->attributes=$_POST['Cidades'];
if($model->save())
$this->redirect(array('view','id'=>$model->id_cidade));
}
$this->render('create',array(
'model'=>$model,
'estados'=>$estados,
));
}
With the var_dump in $estados…
array
0 =>
array
'id_estado' => string '1' (length=1)
'desc_estado' => string 'Minas Gerais' (length=12)
1 =>
array
'id_estado' => string '2' (length=1)
'desc_estado' => string 'São Paulo' (length=10)
2 =>
array
'id_estado' => string '3' (length=1)
'desc_estado' => string 'Rio de Janeiro' (length=14)
3 =>
array
'id_estado' => string '4' (length=1)
'desc_estado' => string 'Bahia' (length=5)
The code than i use the dropDownList is these:
<div class="row">
<?php echo $form->labelEx($model,'Estado'); ?>
<?php echo $form->dropDownList($estados,'desc_estado',array('size'=>10,'maxlength'=>10)); ?>
<?php echo $form->error($model,'desc_estado'); ?>
</div>
But its happening this error when i try run it.
get_class() expects parameter 1 to be object, array given
D:\3NW\Dev\Yii\yii-1.1.8.r3324\framework\web\helpers\CHtml.php(2028)
Hope someone can help me.
Thanks.
Big Hugs