Yii Framework Forum: Problem With Yii::$Objectconfig - Yii Framework Forum

Jump to content

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

Problem With Yii::$Objectconfig

#1 User is offline   stromgol 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 7
  • Joined: 16-March 13

Posted 25 March 2014 - 08:07 AM

I use Yii2 app advanced, updated with Composer, and some of my configuration rencently stopped working (last week end, after an update). In my main config file, under common directory, I used this code to configure gridview for all my views:

 \Yii::$objectConfig = [
		'yii\grid\GridView' => [
                 'tableOptions'=>['class'=>'table table-hover table-striped table-condensed']
		 ],
		],	


Now if I use this same code that used to work, I got a blank page everywhere. My question is how can I configure a widget to have the options available for all the views?

Thanks!
0

#2 User is offline   ORey 

  • Elite Member
  • PipPipPipPipPip
  • Yii
  • Group: Members
  • Posts: 1,689
  • Joined: 20-April 09
  • Location:Moscow, Russia

Posted 25 March 2014 - 08:13 AM

Seems like yii\di\Container::set() is used now.
Here's an example from docs:
$container->set('db', [
    'class' => 'yii\db\Connection',
    'dsn' => 'mysql:host=127.0.0.1;dbname=demo',
    'username' => 'root',
    'password' => '',
    'charset' => 'utf8',
]);


Haven't tested it by myself though.
God is real unless declared as integer
0

#3 User is offline   qiang 

  • Yii Project Lead
  • Yii
  • Group: Yii Dev Team
  • Posts: 5,875
  • Joined: 04-October 08
  • Location:DC, USA

Posted 25 March 2014 - 09:21 AM

Yes, you should DI container now as follows,


Yii::$container->set('yii\grid\GridView', [
	'tableOptions' => [
		'class' => 'table table-hover table-striped table-condensed',
	]
]);

0

#4 User is offline   stromgol 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 7
  • Joined: 16-March 13

Posted 25 March 2014 - 09:47 AM

Thank you very much ORey and qiang. The solution you proposed worked rellay fine. The exact syntax is how qiang presented it. You have to put it in your config file within 'components'.
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