Tag Archives: yii

[HOWTO] Insert widget inside content of CJuiTabs widget in Yii Framework

UPDATE: See the comment from “Mario De Weerd” below. Although it works in the same way, his technique seems more elegant.

I am using Yii PHP Framework 1.1.7 for developing a site. I needed to insert EColorPicker widget inside the content of a tab in CJuiTabs. If $this->widget returned the generated string for embedding a widget, I could use the following code to achieve this:

echo $this->widget('zii.widgets.jui.CJuiTabs', array(
        'tabs' => array(
            'Size' => array('ajax' => array('sizeselection')),
            'Background' => array('content' => $this->widget('application.extensions.colorpicker.EColorPicker',
              array(
                    'name'=>'cp',
                    'mode'=>'textfield',
                    'fade' => false,
                    'slide' => false,
                    'curtain' => true,
                   )
             );),
            //'Colors' => array('ajax' => array('colorselection')),
            'Text' => array('ajax' => array('textselection')),
        ),
        // additional javascript options for the tabs plugin
        'options' => array(
            'collapsible' => true,
        ),
    ));

However, since $this->widget() does not return the string and echoes it instead, I had to do the following to achieve this:

ob_start();
$this->widget('application.extensions.colorpicker.EColorPicker',
              array(
                    'name'=>'cp',
                    'mode'=>'textfield',
                    'fade' => false,
                    'slide' => false,
                    'curtain' => true,
                   )
             );
$colorPicker = ob_get_contents();
ob_end_clean();
    $this->widget('zii.widgets.jui.CJuiTabs', array(
        'tabs' => array(
            'Size' => array('ajax' => array('sizeselection')),
            'Background' => array('content' => $colorPicker),
            //'Colors' => array('ajax' => array('colorselection')),
            'Text' => array('ajax' => array('textselection')),
        ),
        // additional javascript options for the tabs plugin
        'options' => array(
            'collapsible' => true,
        ),
    ));

I don’t know if it is appropriate to use it like this, but in my case this worked fine.

Hope this helps.

[SOLVED] Selenium server not working in Netbeans 6.9.1

I am using Fedora Core 14 and have installed Selenium Module for PHP. I was not able to run PHPUnit tests on Yii Framework. I tried running Selenium server 1.0.1 and upgrade to 1.0.3 solved the problem.

I downloaded the Selenium Remote Control from here and extract the file selenium-server.jar, renamed it to selenium-server-1.0.1.jar and placed it in /home/myusername/.netbeans/6.9/modules/ext/selenium overwriting the old jar. Then I restarted Netbeans. Now, testing works.

Hope this helps.

PHP Error while running newly created Yii Application

If you are using PHP 5.3 and have created a new Yii! Framework 1.1 application, you will get the following error:

date(): It is not safe to rely on the system's timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected 'Your/Timezone' for 'Timezone Info' instead 

To get around this, just open up index.php of your application and in the first line, add the following:

date_default_timezone_set('Timezone/String');

You should replace the ‘Timezone/String’ with your timezone information. Since my timezone is Asia/Kathmandu, I used:

date_default_timezone_set('Asia/Kathmandu');

Hope this helps.