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

Dynamic list of fields #22

Closed
k-bx opened this Issue Jan 5, 2019 · 2 comments

Comments

Projects
None yet
3 participants
@k-bx
Copy link

k-bx commented Jan 5, 2019

I'd like to hear your opinion out on a problem I'm having. My form has a dynamic list of "click trackers" fields, you can add up to three of them. What would be your idea on solving this kind of thing?

"Hacky" way to solve this is to list the fields click_trackers_0, click_trackers_1, click_trackers_2 and render their errors under these names, but maybe you have a better idea.

Thanks!

@tzemanovic

This comment has been minimized.

Copy link
Collaborator

tzemanovic commented Jan 5, 2019

Could it work to parse them into a list and in validation create a list of the same length in the same order with Maybes for errors?

@mrkkrp mrkkrp added the question label Jan 6, 2019

@k-bx

This comment has been minimized.

Copy link

k-bx commented Jan 6, 2019

I guess that's an alternative way to go as well. The problem here is that currently my front-end code just knows that the response for errors is key-value dict where key is String with field name and val is a String with error message. Now it'd have to dynamically see which field has which type. I think I'd prefer the dynamic field name approach here and keep the error structure flat, at least that's my current intuition.

@k-bx k-bx closed this Jan 6, 2019

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