Cannot send value as parameter in activeForm dropdownList

91 views Asked by At

I having problem when try to send value from activeForm dropdownList to event onchange, the result always undefined, is there something wrong with my code?

this is my input form:

<?= $form->field($filter, 'alphabet', ['template' => '{label}{input}{error}{hint}', 'options' => ['class' => 'mb-0']])
   ->dropDownList(
     [
       "" => Yii::t("app", "Sorting by Alphabetical Name"), 
       "AZ" => "A to Z", 
       "ZA" => "Z to A"
     ], 
     ['onchange' => 'dropdownSorting(this.value)','class' => 'form-select', 'data-placeholder' => 'Sorting by Alphabetical Name'])
       ->label(false)
?>
1

There are 1 answers

0
pau On

you may want to attach JavaScript code to handle events, such as button clicks, form submissions, or changes in form fields. Registering JavaScript code in Yii2 is often necessary when you need to include custom JavaScript function that is specific to a particular view or component. Have you registered the dropdownSorting(value) function?

docs