What's the mistake of creating a vision?



  • That's what you're using.

    use frontend\widget\wath\Wath;
    <?= Wath::widget(['serial'=>$model,'theSerial'=>0,'class'=>'film']); ?>
    

    It's like Wath.php.

    class Wath extends Widget
    {
         public $serial;
         public $theSerial;
         public $class;
    
     public function init()
     {
         parent::init();
     }
    
     public function run()
     {
         return var_dump($this-&gt;class);
     }
    

    }

    it's null, but that's if $this->serial I know what comes in. 'serial'=>$model



  • I read the configuration documentation and it refers to the items:

    Note that because the class name is already given, the configuration array should NOT have the class key.

    http://www.yiiframework.com/doc-2.0/guide-concept-configurations.html#widget-configurations

    Or we think:

    Please note that the class parameter is not transmitted because the full name is already indicated.

    https://github.com/yiisoft/yii2/blob/master/docs/guide-ru/concept-configurations.md#%D0%9A%D0%BE%D0%BD%D1%84%D0%B8%D0%B3%D1%83%D1%80%D0%B0%D1%86%D0%B8%D0%B8-%D0%B2%D0%B8%D0%B4%D0%B6%D0%B5%D1%82%D0%BE%D0%B2-


    In general terms, the Yii2 configuration is the following:

    [
        'class' => 'ClassName',
        'propertyName' => 'propertyValue',
        'on eventName' => $eventHandler,
        'as behaviorName' => $behaviorConfig,
    ]
    

    http://www.yiiframework.com/doc-2.0/guide-concept-configurations.html#configuration-format

    In the case of configuration of application and type class Not specified since the class name has already been received...

    For application in the inlet violin:

    (new yii\web\Application($config))->run();
    

    For view (specifically for viewing) Menu😞

    use yii\widgets\Menu;
    

    echo Menu::widget([
    'activateItems' => false,
    'items' => [
    ['label' => 'Home', 'url' => ['site/index']],
    ['label' => 'Products', 'url' => ['product/index']],
    ['label' => 'Login', 'url' => ['site/login'], 'visible' => Yii::$app->user->isGuest],
    ],
    ]);


    In other words, properties class reserved for domestic needs Yii2: to indicate the class we want to create, configurate and use for anything.


Log in to reply
 


Suggested Topics

  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2