Autoform submit problem

hi!, i have a problem with the autoform, i try with
{{>quickform id="armasID" collection="armas" type="insert" autosave="true"}}
and i can insert in my db. but i try to go deeper

{{#autoForm id="armasID" collection="armas" type="method" meteormethod="subir" autosave="true"}} and of course {{/autoForm}}
and i render all the elements, and the validation its ok, (for example, is forgot put “name” and this is required, the error message its displayed). but if it is all ok, it doesn’t call the subir method in the server,

i tried with a button and an event
'click .subirbtn': function(e){ e.preventDefault() Meteor.call('subir', function(err, data) { if(err){ console.log(err); } else{ console.log(data) } });
but I call the method with a undefined data. any solutions?

I had a similar problem with Autoform (though with type=“normal” and handling form submit event myself). What I did was I fired up the Chrome dev tools, set a breakpoint autoform package and step by step investigated what it is doing. It turned out that even though it didn’t say that I had some validation errors, it turned out that there was one (I believe it was an error in my schema). When I fixed that, the problem went away.

Open up aldeed_autoform.js in Sources tab in dev tools and search for this line:

'submit form': function autoFormSubmitHandler

Then set up a breakpoints in there. Hope you’ll find the problem! :slightly_smiling:

i solve this, the problem is was i forgot put
{{> afQuickField name=‘Autor’ }}

the autor, and date is hidden in my schema, and i think i don’t need put this in the {{#autoform

i put all field in autoform, and submit ok!. thanks.

If you have fields in your schema that you don’t want to be in the form, use Autoform before hooks to set the data for these fields after the user submits the form but before the validation. That’s the proper way to deal with such a situation.

1 Like

thanks, my way function ok, but, its good use the best practiques. thanks!

1 Like