Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix spoiler submit #177

Merged
merged 1 commit into from Nov 15, 2019
Merged

Fix spoiler submit #177

merged 1 commit into from Nov 15, 2019

Conversation

poke
Copy link
Member

@poke poke commented Feb 14, 2019

This removes the validation on the text field to prevent the validation that is built into browsers from preventing the form submission.

The form submit would usually trigger a function that copies over the content from the fancy editor into the plain (but hidden) text field. But since the form submission is prevented, that function never runs and
never makes the form valid even if content was added.

The downside of this change is that you can submit with an empty text field but I would say that is not a real issue for users of this service.


I was not able to actually test this, so I would appreciate if someone could give it a try and see if it works :D Ideally, the required attribute should be gone on the textfield of the form.

Remove validation on the text field to prevent the validation that is
built into browsers from preventing the form submission.

The form submit would usually trigger a function that copies over the
content from the fancy editor into the plain (but hidden) text field.
But since the form submission is prevented, that function never runs and
never makes the form valid even if content was added.

The downside of this change is that you can submit with an empty text
field but I would say that is not a real issue for users of this
service.
@davidism
Copy link
Member

I think it might be possible to remove the required flag while still validating the input server side.

@davidism
Copy link
Member

Possibly {{ field(required=False) }}. I'll check when I verify the fix in general.

@poke
Copy link
Member Author

poke commented Feb 14, 2019

I was thinking that too but didn’t know if there was a way to overwrite this behavior (I simply don’t know WTForms well enough for that).

It seems that the InputRequired validator does set the attribute though. But maybe there’s a way to overwrite this attribute in the template call?

<div class="col-md-10">{{ form.message(class='form-control', data_editor='markdown') }}</div>

@kms70847 kms70847 merged commit ac36fc9 into master Nov 15, 2019
@davidism davidism deleted the fix-spoiler-submit branch March 12, 2021 19:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants