grav-plugin-form icon indicating copy to clipboard operation
grav-plugin-form copied to clipboard

Using checkbox along with field.value does not work properly

Open NicoHood opened this issue 3 years ago • 3 comments

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

NicoHood avatar Jan 11 '21 11:01 NicoHood

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

mahagr avatar Jan 12 '21 11:01 mahagr

Done

NicoHood avatar Jan 12 '21 11:01 NicoHood

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.

mahagr avatar Jan 12 '21 11:01 mahagr