yii2-dynamicform icon indicating copy to clipboard operation
yii2-dynamicform copied to clipboard

bug in dynamicform when use kartik Select2

Open zhexinhe opened this issue 9 years ago • 11 comments

q

when added others form group , this issue is "ReferenceError: initSelect2Loading is not defined ", what is the problem?

zhexinhe avatar Jun 30 '15 13:06 zhexinhe

In later versions of kartik-select2 he felt the need to change the external function names: initSelect2Loading -> initS2Loading initSelect2DropStyle -> initS2Open

I'm going to fork

TimNZ avatar Jun 30 '15 19:06 TimNZ

This thread was very helpful! Now I would like to present my problem and maybe someone can give me a hint on how to solve it...

I have a modal with select2 and also dynamic form included in the modal which also includes select2.

The select2 in modal works until I use dynamic form and add another select2 through it. They still work but the search in them doesn't. (Curios is that when the dynamic form select2 is added, the other select2 from the modal has them same problem (search is disabled...)

Can anyone help me with this?

modal code :

http://pastebin.com/SL4FXzCS

_form :

http://pastebin.com/X4C5GdB4

Thank you!

cratemos666 avatar Sep 03 '15 16:09 cratemos666

Another comment about my problem with the modal/dynamic form/select2 is that if I don't go through the modal then everything works as it should...

Thank you !

cratemos666 avatar Sep 03 '15 16:09 cratemos666

try with this version in your composer:

    "wbraganca/yii2-dynamicform": "2.0.2",
    "kartik-v/yii2-widget-select2": "1.0.0"

marcoadasilvaa avatar Nov 14 '15 23:11 marcoadasilvaa

Have some problem. Fix by add function to my script:

function initSelect2Loading(a,b){ initS2Loading(a,b); }

It seems to work..

SanyaBeer avatar Apr 19 '16 11:04 SanyaBeer

Hi, anyone create an pull request? Seems a reasonable solution ;)

philippfrenzel avatar May 31 '16 06:05 philippfrenzel

I solve this problem doing that. Create a js file named dynamicform.js and put on web/js folder. Add js file on the view that i use the modules.

registerJsFile(Yii::$app->getUrlManager()->getBaseUrl().'/js/dynamicform.js',['depends'=>[\yii\web\JqueryAsset::className()], 'position'=>View::POS_END]); ?>

And inside the file dynamicform.js i write this:

function initSelect2Loading(a,b){ initS2Loading(a,b); } function initSelect2DropStyle(id, kvClose, ev){ initS2Open(id, kvClose, ev); }

So, when the module call initSelect2Loading and initSelectDropStyle that will run initS2Loading and initS2Open

DanLivassan avatar Aug 11 '16 23:08 DanLivassan

I'm using this versions "kartik-v/yii2-widget-select2": "@dev", "wbraganca/yii2-dynamicform": "dev-master",

and in the dynamicform.js file I just replaced the init2Open function to initS2ToggleAll function, like @DanLivassan said. function initSelect2Loading(a,b){ initS2Loading(a,b); } function initSelect2DropStyle(id, kvClose, ev){ initS2ToggleAll(id, kvClose, ev); }

I don't know if this was usefull for someone, but I hope so.

Lachos avatar Sep 22 '17 02:09 Lachos

image

This works for me, thank you. By the way, can someone pull request this solution?

dinzrus avatar Mar 08 '18 02:03 dinzrus

@Lachos

This works for me too. Thanks

aludayanan avatar Aug 13 '18 09:08 aludayanan

@dinzrus not working Uncaught TypeError: Cannot read property 'settings' of undefined

pptyasar avatar Oct 22 '18 18:10 pptyasar