i need to add a class and a function to a dropdownlist in Yii2 activeform, here's the code:
<?= $form->field($model, 'tipocontratto')->dropDownList(['RES' => 'Residenziale', 'BUS' => 'Business'], ['prompt'=>'Seleziona...'],['maxlenght'=> true]); ?>
I need to specify a class for the field and also a javascript function.
In normal textfield i make this way:
field($model, 'cogn_ragsoc')->textInput(['maxlength' => true,'class'=>'form-control formtesto','onfocus'=>'test()']) ?>
andd it works perfectly, but in dropdownlist it doesn't
How can i do?
This works perfectly.
<?= $form->field($model, 'tipocontratto')->dropDownList(['RES' => 'Residenziale', 'BUS' => 'Business'], ['prompt'=>'Seleziona...','class'=>'yourclass','onchange'=>'function()']); ?>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With