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

Show validation errors to user when creating a new form #1308

Merged
merged 2 commits into from Jun 9, 2019

Conversation

okahilak
Copy link
Contributor

closes #1292

@okahilak okahilak force-pushed the show-form-validation-errors-to-user branch from dd1897f to c647994 Compare June 3, 2019 10:10
@@ -27,20 +28,32 @@
(map key-to-id)
(str/join "-")))

(defn- get-error [context keys]
(when (:get-form-errors context)
(let [form-errors @(rf/subscribe [(:get-form-errors context)])]
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would prefer that the component contains the subscription and not a random function that gets called. You could give the form-errors as parameters into this fn. In this case the subscription is duplicated into the call sites but at least it's more obvious that the component requires data.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done


(fn [{:keys [db]} [_ request]]
(let [form-errors (validate-form (db ::form) (db :languages))]
(when (nil-vals? form-errors)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would try to restructure the data so that this condition can be a plain empty?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done, good suggestion, I think it's better now

src/cljs/rems/administration/create_form.cljs Outdated Show resolved Hide resolved
@okahilak okahilak requested a review from Macroz June 6, 2019 14:23
@Macroz Macroz merged commit 0abcce0 into master Jun 9, 2019
@Macroz Macroz deleted the show-form-validation-errors-to-user branch June 9, 2019 19:55
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.

vTHL4: visualize validation errors in form creation
2 participants