Allow default values for absent server_fn argument deserialization #1745
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This allows form submission with checkbox inputs to work.
For example:
Arguments absent in the request to the server API will use the Default::default() constructor.
Discussion
Maybe this could be restricted to only certain types; at the moment bool and String need it (for checkboxes and radio buttons) and I don't see a way to customize the (de)serialisation.
Another attempted workaround was to add
<input type"hidden" name="is_good" value="false"/>
immediately before the checkbox; serde refuses to deserialize a field that appears twice but that could probably be tweaked as well.