Saturday, 15 January 2011

meteor - Boolean in nested schema causing required state -


I have set up so that I have an array of complex input sets. Some types:

  address = {street: {type: string}, city: {type: string}, active_address: {type: boolean, optional: true}, ...} People: {Name: {type: string}, address: {type: [address], optional: true, defaultValue: []}}  

Adding an address like this is optional, but if you All address fields are required to add an address

Trying to submit the form throws a necessary error for each field under "addresses" except boolean Even if the checkbox is not checked.

For reference, I am creating the form as:

  {{# autoForm collection = "people" id = formId type = "insert" doc = getDocument Autosave = true template = "auto-update"}} {{& gt; AfQuickField name = 'name' template = "autoupdate" placeholder = "schema label"}} {{& gt; AfQuickField name = 'address' template = "autoupdate"}} ... {{/ autoForm}}  

I am using custom code templates based on bootstrap3 very heavy Form templates that come with auto form

Tried

Tried to add a hook like this:

< Pre> formToDoc: function (doctor, ss, formId) {for (var i = 0, l = doc.address.length; i & lt; l; ++ i) {if (! Doc.address [ I] .active_address) {Delete doc.address [i] .active_address; }; } Return Doctor; }

that resolves to submit the problem, but still puts an array filled with empty string "" for other values, due to which the update form is disturbed The reason for this is that, as I have illustrated,

The issue is that the array is not empty, but instead it is an object of empty values. I can probably run every value in the form and remove all the fields I can, but it is very hack and expensive Is.

In my previous evaluation I was wrong I defaultValue: [] person schema The address in the field was removed from the formToDoc fixes this problem with the following code in the hook:

 for  (var i = 0, l = doc. Address.length; i & lt; l; ++ i) {if (! Doc.address [i] .active_address) {doc.address [i] .active_address = null; }} Returning Doctor;  

No comments:

Post a Comment