Field Submission Data

By default, a field sends anID and field value to the server for processing on form submission. This minimal payload greatly reduces the size of the submitted request, as compared to sending all associated model data for each field.

In some instances, a field type may need to send additional data along with the submission request. The submission data for each field can be modified using the Backbone Radio request for get:submitData on the specific field type channel.

The callback receives a single parameter, fieldData, as an object with the id and value properties already defined. Additional data can be added to the returned fieldData object.

The below example is a reply to the get:submitData request on the textbox field  channel.

var myCustomFieldController = Marionette.Object.extend({
fieldType: 'textbox',
initialize: function() {
Backbone.Radio.channel( this.fieldType ).reply( ‘get:submitData’, this.getSubmitData );
},
getSubmitData: function( fieldData ) {
fieldData.foo = 'bar';
return fieldData;
}
});
new myCustomFieldController();