Yiistrap Bug?

Hi,

I’m using YiiStrap + YiiWheels. Has anyone encountered this error:


include(TbHtml.php): failed to open stream: No such file or directory

while putting yiiWheel’s grid view widget before yiistrap’s modal widget




<?php //Create grid view

    $this->widget('yiiwheels.widgets.grid.WhGridView', array(

	'filter'=>$dataProvider,

	'fixedHeader' => true,

	'headerOffset' => 40, // 40px is the height of the main navigation at bootstrap

	'type'=>'striped bordered',

	'dataProvider' => $dataProvider->search(),

	'template' => "{items}",

	'columns' => $gridColumns,

    ));


<?php //Create modal

    $this->widget('bootstrap.widgets.TbModal', array(

        'id'=>'myModal',


        //header/title of modal

        'header' => 'Sample Modal',

        

        //modal content

        'content' => 'content',

        

        //footer where the modal's buttons are located

        'footer' => array(            

            TbHtml::button('Close', array('data-dismiss' => 'modal')),

            TbHtml::button('Create', array('data-dismiss' => 'modal', 'color' => TbHtml::BUTTON_COLOR_PRIMARY)),

            ),

        )); 

?>


<?php //Button that opens modal

    echo TbHtml::button('Create New Transaction', array(

        'style' => TbHtml::BUTTON_COLOR_PRIMARY,

        'size' => TbHtml::BUTTON_SIZE_LARGE,

        'data-toggle' => 'modal',

        'data-target' => '#myModal',

    )); 

?>



It’s weird 'cause when I place the modal widget before the grid view widget, everything works just fine. is this some kind of bug? Do you guys have any idea how to fix this?

I think you need to add a "\" before TbHtml,




\TbHtml::button(....



or insert complete namespace path of TbHtml

Are you using Yii or Yii2 ?

Have you followed instructions at

http://www.getyiistrap.com/site/started

?

Hi Fabrizio,

I tried your first solution but it didn’t work. I’m currently using Yii and yes, I followed the instructions on yiistrap.

Check you main.php. Seems that an import is missing.

This is from Yiistrap:




<?php

// main configuration

return array(

	...

    // path aliases

    'aliases' => array(

        ...

        'bootstrap' => realpath(__DIR__ . '/../extensions/bootstrap'), // change this if necessary

    ),

    // import paths

    'import' => array(

        ...

        'bootstrap.helpers.TbHtml',

    ),

    // application modules

    'modules' => array(

        ...

        'gii' => array(

            'generatorPaths' => array('bootstrap.gii'),

        ),

    ),

    // application components

    'components' => array(

        ...

        'bootstrap' => array(

            'class' => 'bootstrap.components.TbApi',   

        ),

    ),

);



I have the necessary imports as what you have instructed but the error is still there.

Ummm… I think this has gone a bit weirder. I tried placing the modal widget before and after the gridview widget and everything rendered perfectly (both modals worked). But when I remove the widget before the gridview, the error is produced. Any insights on this one? I’m a bit confused now… ???

Sorry. It’s not the modal that’s wrong, it’s the TbHtml::button(). But still, the error is produced when I placed my button after the gridview widget. somehow the web app couldn’t see the TbHtml.php.

It’s fixed!

I imported the TbHtml.php right after the gridview widget.




<?php //Create grid view

    $this->widget('yiiwheels.widgets.grid.WhGridView', array(

        'filter'=>$dataProvider,

        'fixedHeader' => true,

        'headerOffset' => 40, // 40px is the height of the main navigation at bootstrap

        'type'=>'striped bordered',

        'dataProvider' => $dataProvider->search(),

        'template' => "{items}",

        'columns' => $gridColumns,

    ));

?>


<?php

    Yii::import('bootstrap.helpers.TbHtml');

?>


<?php //Button that opens modal Create Transaction

    echo TbHtml::button('Create New Transaction', array(

        'style' => TbHtml::BUTTON_COLOR_PRIMARY,

        'size' => TbHtml::BUTTON_SIZE_LARGE,

        'data-toggle' => 'modal',

        'data-target' => '#scdCreateTransaction-modal',

    )); 

?>



I did try importing the TbHtml class before the gridview widget but the error is still produced. It would be great if someone could explain this. Could this have anything to do with the yiiwheel widget being read first or something? :mellow: