[Solved] Select2 - Problem with required fields


I have a problem when i submit a form, all fields are required but the page is refresh and all fields are cleared. (because i’m using select widget)

I saw this post, but i dont know where i can put that code, i tried $this->registerJS($js), but doesnt work.


Anyone can help me?

Thank you

It is better to avoid third party widget with lots of dependencies unless no other solution is available.

In my case, my yii-datepicker widget stopped working all of a sudden. When I checked the code, the coding is efficient and with no mistake I could find.

The culprit was a jQuery updation which happened when I downloaded another extension through composer. The bootstrap datepicker widget throws an error in jQuery 2.2x and it works fine with jQuery 2.1x.

Please be ready to solve yourselves these problems as the authors can any time stop supporting the third party extensions.

Problem solved.

I can’t add ID in option of widget…


‘options’ => [‘placeholder’ => ‘— Type —’, ‘class’ => ‘form-control’, 'id => 'type],

After: (working)

‘options’ => [‘placeholder’ => ‘— Type —’, ‘class’ => ‘form-control’],