php - Form made in Yii returns error, Property is not defined -
i have controller ecommercecontroller.php , looks this:
public function actionlegalisation() { $model = new product(); $this->render('legalisation', array('model'=>$model, 'documents'=>$documents, 'countriesissued'=>$countriesissued, 'countries'=>$countries, 'flag'=>$flag)); }
and in legalisation view have:
<?php $form=$this->beginwidget('cactiveform', array( 'id'=>'legalisationform', 'action' => $this->createurl($this->id."/".$this->action->id), 'enableajaxvalidation'=>true, 'clientoptions' => array( 'validateonsubmit'=>true, 'validateonchange'=>true, 'validateontype'=>false, ), )); ?> <table> <tr> <td> <?php echo $form->dropdownlist($model, 'countriesissued', $select = array($_post['countriesissued'])); ?> </td> </tr> </table>
this code return me cexeption property "product.countriesissued" not defined.
when of using chtml , got dropdown list full countries name, this:
<?php echo chtml::dropdownlist($form, 'countriesissued', $select = array($_post['countriesissued']), chtml::listdata($countriesissued, 'code', 'name')); ?>
i need dropdown list field values (countries) can me? thanks.
this bellow code give assistance overcome error facing.
wring in controller
$criteria = new cdbcriteria; $criteria->order = 'country_name asc'; $locations = countries::model()->findall($criteria); $dataary['countries'] = chtml::listdata($locations, 'id', 'country_name'); $this->render('index', $dataary);
write in form
echo $form->dropdownlist($model, 'attribute', $countries, array('prompt' => 'select country')); echo $form->error($model, 'attribute');
for more information please visit http://www.yiiframework.com/forum/index.php/topic/9693-cactiveform-dropdownlist-selectedselected/
Comments
Post a Comment