kartik-v / yii2-widgets

Collection of useful widgets for Yii Framework 2.0
http://demos.krajee.com/widgets
Other
558 stars 175 forks source link

Switch Input bug after second submit form #332

Closed trinkity closed 7 years ago

trinkity commented 7 years ago

This is my configuration:

echo SwitchInput::widget([ 'name' => 'remember_friends', 'value' => ($remember_friends_switch) ? 'on' : 'off', 'pluginOptions' => [ 'state' => $remember_friends_switch, 'size' => 'medium', 'onColor' => 'success', 'offColor' => 'danger', ] ]);

The first time i click on switch button and submit form I've $_POST['remember_friends'] == 'on'. in server side set $remember_friends_switch = true and correctly the switch button show me on state. If i resend submit (WITHOUT click on switch button) the $_POST['remember_friends'] is null !!! Must be on !

trinkity commented 7 years ago

solved with echo SwitchInput::widget([ 'name' => 'remember_friends', 'value' => ($remember_friends_switch==1) ? 1 : 0 , 'pluginOptions' => [ 'state' => $remember_friends_switch, 'size' => 'medium', 'onColor' => 'success', 'offColor' => 'danger', ] ]);