0

I try to render widget into another widget and I have trouble with assets.

class MyWidget extends Widget
{
    public function run()
    {
        $form = ActiveForm::begin();
        ActiveForm::end();
    }
}

In browser console i have jQuery(...).yiiActiveForm is not a function message.

If I add \yii\widgets\ActiveFormAsset::register($this) into layout then all works.

verybadbug
  • 899
  • 1
  • 9
  • 16
  • Sometimes this happens if you run 2 versions of jQuery, by default Yii2 already loads jQuery assets with YiiAsset, and ActiveForm has dependency of YiiAsset, check in "head" and at end of "body" if you have duplicate of jquery running. – Luka Camernik Jun 07 '18 at 10:03
  • There are no jquery duplicate.... Its seems strange, but there are no ActiveForm js in "head" or "body".... so register assets in view file is right suggestion, but it's dirty – verybadbug Jun 12 '18 at 04:28

0 Answers0