Standard template for ActiveField dropdownlist

Hi,

I’m wondering if it is possible to create a custom standard-layout for ActiveField dropdownlists.

Currently I have to use inputTemplate EVERY single time when creating a dropdown.




$form->field($refugee, 'family_situation', [

    'options' => [

        'class' => "col-xs-12 col-sm-6",

    ],

    inputTemplate' => '<div class="select-wrapper">{input}</div> ',

])->dropDownList(...);




yii\widgets\ActiveForm has some configuration for checkboxes and radios, but not for dropdowns :(.

So my idea was to overwrite the dropDownList()-method of ActiveField, but then I have the problem to get ActiveForms to use the new class instead of the standard one.

Maybe I’m missing out on a good other opportunity to solve my problem, I appreciate your suggestions :)

Cheers Nik

Actually I solved my problem myself by reading carefully :D

ActiveForm has the field


$fieldClass

to exactly do this.

So I could extend ActiveForm and tell it to use my custom ActiveField-class (extends from ActiveField). Just if anyone will run into the same problem in the future ;)

Or use container: http://www.yiiframework.com/doc-2.0/guide-concept-di-container.html#practical-usage