formers / former

A powerful form builder, for Laravel and other frameworks (stand-alone too)
https://formers.github.io/former/
1.34k stars 205 forks source link

Checkbox using check() always checked after form error #567

Closed yannrobin closed 6 years ago

yannrobin commented 6 years ago

Hello

I am using this to generate my checkbox :

<?= Former::checkbox( 'checkbox' )
        ->label( '&nbsp;' )
        ->text( 'Primary Infrastructure' )
        ->checked_value( 1 )
        ->unchecked_value( 0 )
        ->check()
    ?>

So my checkbox is checked by default, if I uncheck it and submit the form with a rules error from an other input I will be redirected to the form with the error message but the checkbox will be checked while it was uncheck before submit.

Am i doing something wrong or its an issue ?

Thanks

yannrobin commented 6 years ago

Fixed by changing in the following the config/former.php

'push_checkboxes' => true, 'unchecked_value' => 0,

And adding ->value(1) to the checkbox