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

Using input fields inside form #7

Closed
L1qu1d1c3 opened this issue Nov 4, 2018 · 3 comments
Closed

Using input fields inside form #7

L1qu1d1c3 opened this issue Nov 4, 2018 · 3 comments

Comments

@L1qu1d1c3
Copy link

Hello,

First of all, gotta say that this feature is awesome, works like a charm.

I'd like to mention that if I use the color picker inside a form, when I send the information to the back-end, I receive a lot of unnecessary information, because since the color picker has input fields with the "name" attribute, all this data gets saved, even if I disable HSL and RGB picker, they're still in the DOM but not rendered, so I get the numbers anyway.

Is there any way to solve this? A way to not send everything on submit.
What I have on my form is a hidden input field that I change the value using the .onChange property when instancing it. Like this:
const picker = AColorPicker.createPicker({ attachTo: 'div.colorPicker', showHSL: false, showRGB: false }).onchange = (picker) => { $('input#color').val(picker.color); };

@narsenico
Copy link
Owner

Hi @L1qu1d1c3 ,
you're right, all fields, even hidden ones, have the attribute name. In this way all of them are submitted.
I'll fix it as soon as possible.

@L1qu1d1c3
Copy link
Author

Hi @narsenico,
Its fine and it would be an expected behaviour and I can work around it, but what I think is that if you disable certain features, like rgb or hsl, it shouldn’t even render them in the DOM.

Thanks

@narsenico
Copy link
Owner

Hi @L1qu1d1c3 ,
try new version 1.1.4, unused DOM elements will no longer be rendered.
I also removed the "name" attribute from all input elements.

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

No branches or pull requests

2 participants