-
Notifications
You must be signed in to change notification settings - Fork 439
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
Format input value for server side #220
Comments
Why can't you transform the data before sending it to the server? |
Thanks for the quick reply.
I use it in vanilla JS, so each elements with the class |
This isn't related to my plugin, but to your place in the code where you send the data to the server. There you need to transform the data to your required format (probably) |
Ok i was hoping for a way to just leave the input with the actual values separated by the delimiter. I think you can close the issue then. |
I prefer the developer who implements the solution to take care of value format transformation in their end rather than implementing some solution within Tagify to customize the value's format. |
Having the values passed in as a simple array would be great. This package is great, but having to deal with parsing the values server-side after a form submit was lame. Either way, minor gripe for what this package offers 😸 |
Example: Form and save when form changes jQuery(document).ready(function ($) {
$input = $('#my-form')
.tagify()
.on('change', function (e, tagData) {
if (tagData === undefined) {
return;
}
// string [{"value":"test"}', '{"value":"test2"}] to JSON Object
var tags = JSON.parse(tagData);
// Converts into a simple array ["test", "test2"], then convert to string "test,test2"
var tags_parsed = tags.map(item => item.value).toString();
// Then you can do some ajax post and send the tags_parsed to the server side.
});
}); https://gist.github.com/douglasmiranda/1c7ddb36eee035687f5f371c77b3ea28 |
For future reference, this is now officially supported by using the |
Hi,
I have an input like this :
But when sending the form on the server side I get :
Is it possible to have it the same way as the initial value ? A JSON format :
Thanks
The text was updated successfully, but these errors were encountered: