getgrav / getgrav/grav-plugin-form

Using checkbox along with field.value does not work properly

Open
#476 3 comments 0 reactions 1 assignee Claimed by @mahagr View on GitHub
Dominant language
PHP
Stars
64
Forks
80
Avg merge
10h 13m
Merged PRs (30d)
9

Description

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

```yaml
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

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.