Skip to content

Instantly share code, notes, and snippets.

@softwarerero
Created December 9, 2013 15:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save softwarerero/7873694 to your computer and use it in GitHub Desktop.
Save softwarerero/7873694 to your computer and use it in GitHub Desktop.
Meteor Autoform - No update, no callback called.
<head>
<title>autoform02</title>
</head>
<body>
{{> consulta}}
</body>
<template name="consulta">
<p>The value ruc is never updated in the db. None of the callback on autoforms is called.</p>
{{#autoForm schema=scheme doc=doc}}
{{afQuickField "ruc"}}
<button type="submit" class="update">Guardar</button>
{{/autoForm}}
</template>
Consultas = new Meteor.Collection2("consultas", {
schema: {
ruc: {
type: String,
label: "RUC"
}
}
});
Consultas.allow({
insert: function() {
return true;
},
update: function() {
return true;
},
remove: function() {
return true;
},
fetch: []
});
if (Meteor.isClient) {
Meteor.subscribe("consultas");
ConsultasForm = new AutoForm(Consultas);
ConsultasForm.hooks({
before: {
update: function(doc) { console.log("update"); return doc}
},
after: {
update: function(error, template) { console.log("error on update")}
},
onSubmit: function(error, result, template) { console.log("submit"); true}
});
Template.consulta.helpers({
scheme: function() {
return Consultas;
},
doc: function() {
return Consultas.findOne({ ruc: "123456" });
}
});
};
if (Meteor.isServer) {
Consultas.remove({});
Consultas.insert({"ruc": "123456"});
Meteor.startup(function () {
Meteor.publish("consultas", function() {
Consultas.find();
});
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment