Hi to all. i have Cars table. One of fields is rating (from 1 to 5). I had created new actionSearch in CarsController and in new "search" view a form:
<div class="row">
<?php echo $form->labelEx($model,'rating',array('label'=>'Rating')); ?>
<?php echo $form->checkBoxList(
$model,
'rating',
$model->getRatingOptions(),
); ?>
<?php echo $form->error($model,'rating'); ?>
</div>
in Cars model:
public function searchAdv()
{
$criteria=new CDbCriteria;
$stars = $this->rating; //it's wrong way
$criteria->select='id,car,stars';
$criteria->condition='stars IN ('.$stars.')';
return new CActiveDataProvider(get_class($this), array(
'criteria'=>$criteria,
));
}
in controller:
public function actionSearch()
{
$model=new Cars;
$model->attributes=$_POST['Cars']; // here i put checked ratings
$this->render('search',array(
'model'=>$model,
));
}
And the question is: How can i access $_POST[‘cars’] array from Cars model? Because $model->rating is empty.
$stars = $this->rating; //here must be checked array of rating, for ex: 1,5.
P.S.: sorry for amateurish question