Giter Club home page Giter Club logo

Comments (7)

Pagebakers avatar Pagebakers commented on August 18, 2024

I haven't build any dynamic forms with the package yet, but I think it can be done by reading the data from the previous step (with wizard.mergedData() for example) and build your schema based on the values.

from meteor-wizard.

kylepierce avatar kylepierce commented on August 18, 2024

I guess my issue is how can I save each step? Should I use onSubmit or something else? Apologies I am unfamiliar with autoform and simple schema.

from meteor-wizard.

Pagebakers avatar Pagebakers commented on August 18, 2024

The same questions was asked here #18, I'll setup an example tomorrow.

from meteor-wizard.

kylepierce avatar kylepierce commented on August 18, 2024

Examples would be extremely helpful. Thank you!

from meteor-wizard.

Pagebakers avatar Pagebakers commented on August 18, 2024

If you want to save each step, you can use onSubmit on every step, save the data in a collection, and call wizard.next(). Something like this:

  {
      // step configuration here
      onSubmit: function(data, wizard) {
        // save your data and call wizard.next(data) on succesfully saving the data.
        wizard.next(data);
      }
    }

Then to show fields based on input from the previous step you could do something like this.

Template.dynamicStep2.helpers({
  camperFields: function() {
    var data = this.wizard.mergedData(); // this gets all data from previous steps, you can also retrieve the data from a collection, if you're saving it manually.
    var amount = data && data.campers;
    var fields = [];
    for (var i = 0; i < amount; i++ ) {
      fields.push({
        index: i,
        name: 'campers.' + i + '.name'
      });
    }
    return fields;
  }
});

And in your form template do:

    {{#each camperFields}}
      <div class="ui vertical segment">
        <h3 class="ui header">Camper {{index}}</h3>
        {{> afQuickField name=name}}
      </div>
    {{/each}}

from meteor-wizard.

kylepierce avatar kylepierce commented on August 18, 2024

Thank you. I was on the right track, however I am still running into the problem that onSubmit is not working because it requires the next form's input. Error: Number of Campers is required a question on the following step.

from meteor-wizard.

Pagebakers avatar Pagebakers commented on August 18, 2024

It's hard to say what's going on without seeing some code.

from meteor-wizard.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.