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

Form Builder / Picker - after clearing value from required field form validation passes on submit #304

Closed
Tomasz-Zlamaniec opened this Issue Sep 7, 2016 · 1 comment

Comments

Projects
None yet
2 participants
@Tomasz-Zlamaniec
Copy link

Tomasz-Zlamaniec commented Sep 7, 2016

Hexagon version: 1.6.0

Expected

A form is created with a required picker. When user tries to submit the form then validation error is shown because the value is empty. After setting the value the form can be submitted. After submitting the form the value is removed using form.value(field, undefined), when the user submits the form again the validation error should be shown.

Actual

If form passes validation with a value in picker and the value is removed problematically then next validation will pass even though the required field has no value.

Example

const FIELD = "My Field";

var form = new hx.Form('#form')
    .addPicker(FIELD, ["A", "B", "C"], {required: true})
    .addSubmit("Submit");

form.on("submit", () => setTimeout(() => form.value(FIELD, undefined), 2000));

Select a value, click submit, wait 2 seconds, click submit again and there is no validation error:

image

@c-frater

This comment has been minimized.

Copy link
Contributor

c-frater commented Sep 30, 2016

This is because the picker is not correctly re-setting the validation message. Updating the setCustomValidity to be hx.userFacingText('form', 'pleaseSelectAValue') when the value from the change event is undefined
https://github.com/ocadotechnology/hexagonjs/blob/master/modules/form-builder/main/index.coffee#L124

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment