jonjamz / blaze-forms

Dead easy reactive forms with validation (Meteor).
https://atmospherejs.com/templates/forms
MIT License
113 stars 11 forks source link

Add support for nested objects (in schema or otherwise) #28

Closed steph643 closed 9 years ago

steph643 commented 9 years ago

Here is my code:

<template name="myForm">
    {{#defaultFormBlock schema=schema action=action data=data}}
        {{> myInput field='field1'}}
        {{> myInput field='nested.field2'}}
        <button type="submit" disabled="{{#if context.invalidCount}}disabled{{/if}}">Submit</button>
    {{/defaultFormBlock}}
</template>
schema: function ()
    {
    return new SimpleSchema(
        {
        field1: { type: String, max: 3 },
        nested: { type: Object },
        'nested.field2': { type: String, max: 3 }
        });
    },

data: function()
    {
    return { field1: '111', nested: { field2: '222' } };
    },

First issue is that data does not initialize nested.field2.

Second issue is that nested.field2 input is validated erratically: the latest error message seems to remain even if input is ok, until a new error is detected and replace the previous one.

jonjamz commented 9 years ago

This makes sense. I'll have to add this functionality.

priojk commented 9 years ago

I just ran into the same issue. May I ask, if you already have an estimate, by when this could be fixed?

jonjamz commented 9 years ago

I can probably do end of week on this. Thanks!

jonjamz commented 9 years ago

Made progress on this and will publish the changes once I finish more testing.

jonjamz commented 9 years ago

I tested this a bunch and it seems to be working. Please let me know how it goes for you. Thanks!

steph643 commented 9 years ago

I will test this today.

steph643 commented 9 years ago

It works like a charm, thanks a lot!

priojk commented 9 years ago

Just tested it - works flawless in my app. Thank you very much!