Yii: The system is unable to find the requested ac

2019-03-04 17:39发布

what i am doing is trying using the yii select2 extension to create a searchable dropdown list. i have downloaded the extension from this link and following it "http://www.yiiframework.com/extension/select2/". i have put the unzipped file(which is select2) in protected/extensions and i have then created a php file in "protected/views/site/select.php" in which i pasted the code below and when i try to run it via "webapp/index.php/site/login" it gives this error " Error 404 The system is unable to find the requested action "select"." Please help me with this, thankyou..!!

 //code in select.php(protected/views/site/select.php)
$tags=array('Satu','Dua','Tiga');
echo CHtml::textField('test','',array('id'=>'test'));
$this->widget('ext.select2.ESelect2',array(
'selector'=>'#test',
'options'=>array(
'tags'=>$tags,
),
));

1条回答
家丑人穷心不美
2楼-- · 2019-03-04 18:11

It seems that you have make the view file (protected/views/site/select.php) but you don't have created the corresponding action.

Add in SiteController:

public function accessRules() {
    //You can modify accordingly but you have to insert select to allowable actions
   return array(
        array('allow',  // allow all users to perform 'index', 'contact' and 'select' actions
            'actions'=>array('index', 'contact', 'select'),
            'users'=>array('*'),
        ),
        array('deny',  // deny all users
            'users'=>array('*'),
        ),
    );
}

 public function actionSelect() {
    $this->render('select');
}
查看更多
登录 后发表回答