I'm trying to POST a form using extjs. I have tagfields that need to be sent as json arrays. Here is one tagfield:
{
xtype: 'tagfield',
fieldLabel: 'Product(s)',
name: 'productIds',
store: {
type: 'products'
},
valueField: 'productId',
displayField: 'productName',
encodeSubmitValue: true //this is supposed to send an array per https://docs.sencha.com/extjs/6.0/6.0.0-classic/#!/api/Ext.form.field.Tag-cfg-encodeSubmitValue
}
Here is the Ajax submit:
Ext.Ajax.request({
url: 'api/events/create',
method:'POST',
headers: { 'Content-Type': 'application/json' },
params : Ext.JSON.encode(form.getValues()),
success: function(form, action) {
Ext.Msg.alert('Success', action.result);
},
failure: function(form, action) {
//console.log(form.getForm().getValues());
Ext.Msg.alert('Submission failed.', 'Please make sure you selected an item for each required field.', action.result);
}
});
The JSON payload ends up looking like this:
{ "productIds": "[1,2]" }
The above array cannot be deserialized out of the string (the backend uses Jackson to de-serialize).
Does anyone know how to send the above as { "productIds": [1,2] }
?