How can i get the values of the form inputs in a dynamic template that consist of different templates/steps with multiple input values? I know that this can be done with helpers on each template but for flexibility reasons I would like to keep each step’s form values(and not create multiple helpers for all these different form inputs) , in the formData element of the instance.steps object so that to further check whether they have been filled in etc can that be done and how?
I wrote the helper function in formData in order to get the value of the id driving_license which is in the template stepTwo as you can see below, I cannot get anything thought, I also tried
` dl= parseInt($(‘input[name=```“driving_license”]:checked’).val())
but it also does not give me anything.
Template.experiment.onCreated(function () {
const instance = this;
instance.step = new ReactiveVar('stepOne');
instance.steps = {
formData:{
'change #driving_license':async function (event, instance){
event.preventDefault();
dl=parseInt($(event.target).val(), 10)
console.log('dl',dl)
return dl
},
},
stepOne: {
nextStep: 'stepTwo',
title: 'Start',
},
stepTwo: {
step:'stepTwo',
nextStep: 'stepThree',
title: 'Next Part'
},
stepThree: {
nextStep:'stepFour',
title:'Next',
},
stepFour: {
message: '<h2>You did it, you finished all steps</h2>',
},
};
{{>Template.dynamic template=stepTemplate data=stepData }}
```
<template name="stepTwo">
<div class="form-check-inline">
<label class="form-check-label">
<input type="radio" class="form-check-input" name="driving_license" id="driving_license" value="1">Yes
</label>
</div>
<div class="form-check-inline">
<label class="form-check-label">
<input type="radio" class="form-check-input" name="driving_license" id="driving_license" value="2">No
</label>
</div>
</template>