Tagify: Format input value for server side

Created on 23 Apr 2019  路  6Comments  路  Source: yairEO/tagify

Hi,

I have an input like this :

<input class="tags" type="text" name="keywords" value='["repellat inventore","magni accusamus"]'>

But when sending the form on the server side I get :

[
    {"value":"repellat inventore"},
    {"value":"magni accusamus"}
]

Is it possible to have it the same way as the initial value ? A JSON format :

["repellat inventore","magni accusamus"]

Thanks

Help wanted

Most helpful comment

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 馃樃

All 6 comments

Why can't you transform the data before sending it to the server?

Thanks for the quick reply.
It's not that I can't it's that I don't know where to do it within the plugin declaration :

new Tagify(element, {
    delimiters: ',',
    duplicates: false,
    autocomplete: true,
    addTagOnBlur: false
});

I use it in vanilla JS, so each elements with the class .foo uses your plugin and the input value shoud be just the values, as the ones passed in. Is there a callback to transform the actual input values ?

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 馃樃

Was this page helpful?
0 / 5 - 0 ratings

Related issues

conquext picture conquext  路  3Comments

collimarco picture collimarco  路  3Comments

mzangari picture mzangari  路  4Comments

biznickman picture biznickman  路  6Comments

erniomaldo picture erniomaldo  路  5Comments