Friday, November 30, 2012

Yii Bootstrap Issue 

Twitter Bootstrap is a CSS Framework. It is provided by Twitter. This Framework has provided a lot of predefined CSS code. Using these code you can easily and fast you can build and design your website. So basic of this Framework is less code more effect. Here you can find :

  • Well define form structure
  • Good and attractive Button design
  • Support of Jquery Library
  • Support of Less code
  • Etc...
Here I am not trying to enplane Bootstrap Framework. There is already well documentation is present on the INTERNET.

Yii also support Bootstrap i.e Bootstrap integration with Yii framework has already been done.  You can find details here : Yii Bootstrap .

Ok , so I am here explain some issue which I use to get during development.

Issue 1 (Table) :
This issue I got when I was trying to display a table with some content.  

Example :


$gridDataProvider = new CArrayDataProvider(array(
    array('id'=>1, 'firstName'=>'Mark', 'lastName'=>'Otto', 'language'=>'CSS'),
    array('id'=>2, 'firstName'=>'Jacob', 'lastName'=>'Thornton', 'language'=>'JavaScript'),
    array('id'=>3, 'firstName'=>'Stu', 'lastName'=>'Dent', 'language'=>'HTML'),
));

$this->widget('bootstrap.widgets.TbGridView', array(
    'type'=>'striped bordered condensed',
    'dataProvider'=>$gridDataProvider,
    'template'=>"{items}",
    'columns'=>array(
        array('name'=>'id', 'header'=>'#')
        array('name'=>'firstName', 'header'=>'First name'),
        array('name'=>'lastName', 'header'=>'Last name'),
        array('name'=>'language', 'header'=>'Language'),
        ),
));


If you print this on it will not through any error. But if you change 'id' to something else then it will through a error.

Error :

Undefined index: id

Solution

So, Here only solution for solving this you will have to always put 'id'.

Key :  Bootstrap, Yii Framework ,