Closed steph643 closed 9 years ago
Ah--good catch. That totally makes sense.
This should solve it.
Fix works great.
Remaining issue: changed
still does not work if the form was initialized with no data argument (it works well if there was an empty data argument).
{{! Init the form with no data argument}}
{{#myFormBlock schema=schema action=action}}
{{> myInput field='testField'}}
{{/myFormBlock}}
In that case, if user enters something in the input, changed
will be empty instead of containing the new value.
I did it this way on purpose because without initial data nothing will have "changed" and the fields with values would all be in this
in the action function. That way you can use:
if (_.isEmpty(changed)) {
// insert with `this`...
} else {
// update with `changed`...
}
I'll try to make this easier by returning undefined
or false
for changed
if there's no initial value, rather than simply an empty object.
Ok, it makes sense.
If explained in the doc, an empty object is fine (but I think undefined
would be even better).
This seems to be a design choice (cf. this comment). However, a standard use case is that you have an optional field in your collection, initially undefined. In the update form, you enter a value for this field. Then you have to update the collection with this new value. If the field is not present in
changed
, you still have to scanthis
, andchanged
is useless...