Combine dynamic-form and kartik-select2


I’m using

"kartik-v/yii2-widget-select2": "^2.0.0",
"wbraganca/yii2-dynamicform": "*"

and i have a problem, when i’m pushing on plus (+) on my form, i have a new select2, but without data.
and in console i see error:
ReferenceError: initSelect2Loading is not defined[Learn More]

i read many issues, but still can refactor my code for working fine… i see some forks, but after installing - i have same error…

tryed even this

    ['depends' => [\yii\web\JqueryAsset::class]]

maybe somebody knows how can i replace yii2-dynamic-form.js, by my own?

or maybe you know another method, give me please…

Hi @DesRodman,

As you have already figured out, wbragnaca/yii2-dynamicform doesn’t work with the latest version of kartik-v/yii2-widget-select2. It needs an update but it doesn’t look actively maintained these days. It’s a real pity for this useful extension.

What you can do could be:

  1. making a PR to fix the issue (as you have already done),
  2. searching a fork that supports the latest yii2-widget-select2, and/or
  3. making your own fork with the necessary fix.

i’m trying to change yii2-dynamic-form.js for my file, cant understand how it do…

i included own js
but anyway code works from extension

or maybe somebody can give me example how too make fork?

I think you already have a fork.

Isn’t this yours?

You can require wbraganca/yii2-dynamicform from your fork by specifying your repository like the following:

    "repositories": [
            "type": "vcs",
            "url": ""
            "type": "composer",
            "url": ""
    "require": {
        "kartik-v/yii2-widget-select2": "^2.0.0",
        "wbraganca/yii2-dynamicform": "*"

The module name is still “wbraganca/yii2-dynamicform”, but composer will load it from your github repository.

Alternatively, this fork looks nice to me.

It is actively maintained.

Yes, its my attempt to make own fixed extension…
But i never made fork, and now still try to understand what i need to do

I tryed to use this extension and success


PS: in use you should use \bajadev\dynamicform\DynamicFormWidget;
and every thing becomes working