Autoform subSchema


#1

Hello there, i’m most likely googeling the wrong words as i can’t imaginge noone ever had these problems before :confused:
I have a Schema like:

Test.attachSchema(new SimpleSchema({
    sub:{
        type: SubSchema
    },
...
});

And a SubSchema like:

SubSchema = new SimpleSchema({
    subsub:{
        type: AnotherSchema
    },
...
});

How can i create a autoform for this?
My attemp was:

{{#autoForm collection="Test" id="createTestForm" scope="sub.subsub" type="update-pushArray" doc=this}}
    {{> afQuickField name='title'}}
    {{> afQuickField name='message'}}
    <button type="submit" class="btn btn-primary">Save</button>
{{/autoForm}}

This generates a right looking form, but when submiting it, the form gets cleared and no database entry is made. I don’t get an error anywhere, so i don’t know how to track this down :frowning:

regrads,
thx for any help,
lukas


#2

Hard to say why, you are most probably trying to submit document which does not match the schema.

But we have no way how to help you, as we dont know how is AnotherSchema defined.


#3

Okay I attached the other Schema, but my question is more on how to debug this(even if i would be happy to know what’s wrong).

AnotherSchema = new SimpleSchema({
        title:{
            label: "title",
            type: String
        },
        message:{
            label:"Text",
            type:String,
            autoform: {
                type: 'textarea',
            },
            max:500
        },
        createdAt:{
            type: Date,
            autoValue: function () {
                return new Date();
            },
            optional:true
        }
    });

#4

In theory you can use submit type normal and check what is being returned, what is original doc, what is going to be saved etc.
So you can than try to validate it manually and maybe even inserted directly to db by hand.


#5

I possibly could, but than I have to do this over and over again instead of figuring out how autoform actually works…
I just figured out, that neither insert, nor update of my TestCollection is ever called by this form - so sth. with my Form has to be wrong?, i think.


#6

and is current doc really in “this” ?


#7

ahrg thanks for your effots :confused: these #which statements are breaking my neck