-
Notifications
You must be signed in to change notification settings - Fork 79
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixed state of the checkbox if no value is provided
- Loading branch information
Showing
2 changed files
with
7 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
bff6b9d
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is still not correct when the form submission contains errors and the form is rendered again.
This code will set
value
totrue
. And the twig checktrue == '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 ais same as()
check is required here?https://github.com/getgrav/grav-plugin-form/blob/develop/classes/Form.php#L841-L843
Or maybe it would make sense to also patch the
Form.php
code to return the value instead oftrue
. Because if this does not get patched, thesame 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
bff6b9d
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The code doesn't set anything. It just marks checkbox to be checked if
value
equalsfield.value
.The issue is that #472 (review) hack breaks the logic in here as it basically means that checkboxes inside regular forms can not have any other values than
true
andfalse
-- which is not true outside regular form. Basically that also makes yourvalue: 'fun'
to be non-valid expression.bff6b9d
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the 'hack' is still good to have, but requires a fix to also support the
value
option. I know, that this template fix (this commit) is correct by itself, I just wanted to note, that the feature is still incomplete.I've tracked it here real quick: #476