Yii2: onchange, activeDropDownList donot working

Created on 14 Nov 2016  路  3Comments  路  Source: yiisoft/yii2

$form = ActiveForm::begin(); 
    echo Html::activeDropDownList($model, 
                'client_key',
                ArrayHelper::map(ListClient::find()->all(), 'client_key', 'cli_stat_name_l'), 
                ['prompt'=>'All Clients...'],
                ['onchange'=>'this.form.submit()']);
    ActiveForm::end(); 

activeDropDownList onchange didnot working when have ['prompt'=>'All Clients...'],

I comment ['prompt'=>'All Clients...'], it work

| Q | A
| ---------------- | ---
| Yii version | 2.0.10
| PHP version | PHP Version 5.6.3
| Operating system | windows 7

form question to be verified

Most helpful comment

Is your example above as it is in your code? If so you've got the options as two separate parameters which is why it'll work when you comment it out.

Try

echo Html::activeDropDownList(
    $model, 
    'client_key',
    ArrayHelper::map(ListClient::find()->all(), 'client_key', 'cli_stat_name_l'), 
    ['prompt'=>'All Clients...', 'onchange'=>'this.form.submit()']
);

All 3 comments

Is your example above as it is in your code? If so you've got the options as two separate parameters which is why it'll work when you comment it out.

Try

echo Html::activeDropDownList(
    $model, 
    'client_key',
    ArrayHelper::map(ListClient::find()->all(), 'client_key', 'cli_stat_name_l'), 
    ['prompt'=>'All Clients...', 'onchange'=>'this.form.submit()']
);

@Alex-Code is right

Thank you for your question.
In order for this issue tracker to be effective, it should only contain bug reports and feature requests.

We advise you to use our community driven resources:

If you are confident that there is a bug in the framework, feel free to provide information on how to reproduce it. This issue will be closed for now.

_This is an automated comment, triggered by adding the label question._

Was this page helpful?
0 / 5 - 0 ratings

Related issues

alexraputa picture alexraputa  路  53Comments

sapsxxxil picture sapsxxxil  路  50Comments

alexandernst picture alexandernst  路  163Comments

AstRonin picture AstRonin  路  49Comments

rosancoderian picture rosancoderian  路  46Comments