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

[V4]: Manage checkbox as a boolean in stead of text value #2889

Closed
bzd2000 opened this issue Sep 4, 2020 · 7 comments
Closed

[V4]: Manage checkbox as a boolean in stead of text value #2889

bzd2000 opened this issue Sep 4, 2020 · 7 comments

Comments

@bzd2000
Copy link
Contributor

bzd2000 commented Sep 4, 2020

Currently checkbox are managed by an array of the selected checkbox.
But this makes hard to save it in the database as booleans and present it again afterwards

I think it would be better to manage it as a boolean and not as a text value

@bzd2000 bzd2000 changed the title Next: Manage checkbox as a boolean in stead of text value V4: Manage checkbox as a boolean in stead of text value Sep 4, 2020
@bzd2000 bzd2000 changed the title V4: Manage checkbox as a boolean in stead of text value [V4]: Manage checkbox as a boolean in stead of text value Sep 4, 2020
@logaretm
Copy link
Owner

logaretm commented Sep 5, 2020

Do you mind posting a code sample of your example? I assume it's only for the case of single checkboxes?

@logaretm
Copy link
Owner

logaretm commented Sep 5, 2020

closed by 7a08184

@logaretm logaretm closed this as completed Sep 5, 2020
@olemarius
Copy link

I'm still getting array value. I've created a dynamic form component where I loop out the fields from an object that I receive from backend.

<Field :name="name" as="input" type="checkbox" :value="attrs.attrs.value" />  

image

If I'm changing the :name to a hardcoded string, like :name="'name1' it works as expected:

<Field :name="name + '1'" as="input" type="checkbox" :value="attrs.attrs.value" />  

image

@logaretm
Copy link
Owner

logaretm commented Jun 7, 2021

@olemarius If all the loop iterations have the same name then that's expected behavior. If each checkbox is only related to the iteration's item then you should make the name unique for that item like by appending the index.

@olemarius
Copy link

There's only one checkbox in the form, and only one item with that name so I was expecting it to be the same as if I build the form manually rather than generating it based on a json object.

@logaretm
Copy link
Owner

logaretm commented Jun 7, 2021

@olemarius Do you mind creating a minimal reproduction for your issue on codesandbox? could be a bug.

@olemarius
Copy link

@logaretm sorry, the issue was on my side. Works as expected now :-)

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

No branches or pull requests

3 participants