getgrav / grav-plugin-form

Grav Form Plugin
http://getgrav.org
MIT License
53 stars 79 forks source link

Using checkbox along with field.value does not work properly #476

Open NicoHood opened 3 years ago

NicoHood commented 3 years ago

See discussion here: https://github.com/getgrav/grav-plugin-form/commit/bff6b9dab5f7a33b9b0d1799a70c5e3bb05cda0f#commitcomment-45774353

I think this is still not correct when the form submission contains errors and the form is rendered again.

This code will set value to true. And the twig check true == 'fun' will always return true as well. So the whole statement is useless it seems, as simple check against true should be sufficient. Or maybe a is same as() check is required here? https://github.com/getgrav/grav-plugin-form/blob/develop/classes/Form.php#L841-L843

agree_to_terms:
        type: checkbox
        label: "Agree to the terms and conditions"
        default: false
        value: 'fun'

Or maybe it would make sense to also patch the Form.php code to return the value instead of true. Because if this does not get patched, the same as check will fail.

Edit: I think this template also need to be fixed: https://github.com/getgrav/grav-plugin-form/blob/develop/templates/forms/default/data.html.twig#L29

mahagr commented 3 years ago

Could you please copy the current description to here to your first message? :)

NicoHood commented 3 years ago

Done

mahagr commented 3 years ago

Thank you. :)

I will get back to this after Grav 1.7 release, right now we do not want to make quick last minute fixes as they usually end up backfiring us.