Closed thearabbit closed 8 years ago
If it's an update form, you don't need to use step.data
but you can just pass the document to the form.
pass the doc to main form or all step form
// Template
{{> wizard id="productUpdate" steps=steps doc=data.........
// JS
Template.productUpdate.helpers({
data: function () {
var data = Collection.Product.findOne(this._id);
return data;
},
// Step
{#autoForm id="generalStep" schema=step.schema}}......
{{#autoForm id="loanAmountStep" schema=step.schema}}......
{{#autoForm id="chargStep" schema=step.schema}}......
No that's not gonna work, you can reuse the same doc for each step, but best would be to return the doc with only the fields used in the specific form.
{#autoForm id="generalStep" schema=step.schema doc=doc}}......
{{#autoForm id="loanAmountStep" schema=step.schema doc=doc}}......
{{#autoForm id="chargStep" schema=step.schema doc=doc}}......
It mean that don't pass doc to main for, but pass data to each step
// Template
{{> wizard id="productUpdate" steps=steps
// JS
Template.productUpdate.helpers({
steps: function () {
return [
{
id: 'general',
title: 'General',
template: 'generalStep',
formId: 'generalStep',
schema: Schema.Product.general,
data: function () {
var data = Collection.Product.findOne(this._id);
return data;
},
},
..............................
{
id: 'charge',
title: 'Charge',
template: 'chargStep',
formId: 'chargStep',
schema: Schema.Product.charge,
data: function () {
var data = Collection.Product.findOne(this._id);
return data;
},
onSubmit: function (data, wizard) {
var self = this;
var extend = _.extend(wizard.mergedData(), data);
// update doc
}
}
]
}
Yeah I get the idea, but that's not supported at this time. So you have to pass the doc directly to the autoform in your steps.
If you read through the closed issues, there are some examples using an update/insert form.
Thanks, look great :+1:
But now it have problem when I submit update form. It don't get the new value on previous step (It still get the initial value). Please help me.
I would like to initial data for update form. I have 3 steps