Yii Framework Forum: Yiistrap Bug? - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Yiistrap Bug? Rate Topic: -----

#1 User is offline   JoTheNotSoAwesome 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 14
  • Joined: 02-February 14

Posted 28 March 2014 - 06:50 AM

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?
0

#2 User is offline   Fabrizio Caldarelli 

  • Advanced Member
  • PipPipPip
  • Yii
  • Group: Members
  • Posts: 334
  • Joined: 21-March 13
  • Location:Rome, Italy

Posted 28 March 2014 - 06:53 AM

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

\TbHtml::button(....


or insert complete namespace path of TbHtml
0

#3 User is offline   Fabrizio Caldarelli 

  • Advanced Member
  • PipPipPip
  • Yii
  • Group: Members
  • Posts: 334
  • Joined: 21-March 13
  • Location:Rome, Italy

Posted 28 March 2014 - 06:57 AM

Are you using Yii or Yii2 ?

Have you followed instructions at

http://www.getyiistr...om/site/started

?
0

#4 User is offline   JoTheNotSoAwesome 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 14
  • Joined: 02-February 14

Posted 28 March 2014 - 07:04 AM

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.
0

#5 User is offline   Fabrizio Caldarelli 

  • Advanced Member
  • PipPipPip
  • Yii
  • Group: Members
  • Posts: 334
  • Joined: 21-March 13
  • Location:Rome, Italy

Posted 28 March 2014 - 07:06 AM

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',   
        ),
    ),
);

0

#6 User is offline   JoTheNotSoAwesome 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 14
  • Joined: 02-February 14

Posted 28 March 2014 - 07:12 AM

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

#7 User is offline   JoTheNotSoAwesome 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 14
  • Joined: 02-February 14

Posted 28 March 2014 - 08:52 AM

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... ???
0

#8 User is offline   JoTheNotSoAwesome 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 14
  • Joined: 02-February 14

Posted 28 March 2014 - 09:58 AM

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.
0

#9 User is offline   JoTheNotSoAwesome 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 14
  • Joined: 02-February 14

Posted 28 March 2014 - 10:08 AM

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:
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users