yii 1.1x: i get 404 when i try to pass a variable from view to widget

时间:2017-06-12 17:01:39

标签: php yii

In my yii app, i get a date string via ajax get then i try to pass it to my feature widget. The thing is that sometimes i get the date via GET url and sometimes i use a default one that i get directly in the widget (so in that case no variable needs to be passed). Here is the code:

controller:

public function actionGetDate($date) {      
    $this->render('index',array('date' =>$date));
}

The $date passes to the view without any problem.

My view:

if (isset($date))
{
    echo "$date !!!!";
    $this->widget('FullWidget',array('date2' =>$date) );
} else {
    echo "not date";
    $this->widget('FullWidget');
}

when $date is not set, then the code runs without any issue.

when $date is set and then it goes to this line below and it gets me 404 Error..

$this->widget('FullWidget',array('date2' =>$date) );

here is the error:

enter image description here

FullWidget:

class FullWidget extends CWidget {

    private $_userConfig;

    public function init() {

        $this->_userConfig = Yii::app()->getModule('module1234')->getDefaultConfig();     
    }

    public function run() {
    if (isset($date2))
{
    echo "yes!!!";
    //$this->render('small_Widget', array('config' => $this->_userConfig,'date' => $date2));// this line is commented and i dont run it yet. the problem is when i'm trying to pass the variable from the view to the FullWidget    
    }else{
        echo "no!!!!";
        $this->render('small_Widget', array('config' => $this->_userConfig));
    }

}
}

Does anybody knows whats the problem?

Thanks!!

0 个答案:

没有答案