Saving an API form Repeat to session manager

@Teodor

I have found your tutorial on the repeat form to be very helpful.

However I have a question. In my scenario, I need to save the data to the session manager first. The way I have built the form is to create the steps by hiding and showing the next set of questions once the info has been saved to the session manager. I am doing this because I am not saving it to the serverside. Once all the info has been placed into the session manager, the submit button is pressed, the API call happens and the response is sent back and viewed on the page.

My question is the following, when I have the repeat form and the step 3 button is pressed, it does not save the info in the fields to the session manager. On the simpler form, it would save it to the session manager.

this is how the API is triggered

Ok so here is an update to where I am at.

I have now been able to place the data into the session manager. To do this I have had to not only select the .value but also the .items

formRepeat1.OverallVehMilesDrivenPerYear.value+formRepeat1.items

So now my issue is that it does not display the info in the review your info tab.
I have selected the dynamic data field and stated I wanted the value of the session. but is comes back as object.

I am making progress but any help would be appreciated.

Thank you

@Apple @Hyperbytes

Can you show a screenshot of this? I’m not sure I understand the expression you wrote (or if it’s indeed malformed)

hey buddy @Apple hope you are doing well.

check out the attached.

<button id="btnCarbSub2" class="btn btn-primary btn-sm" type="submit" dmx-on:click="session1.set('OverallVehMilesDrivenPerYear',formRepeat1.item.OverallVehMilesDrivenPerYear.value);session1.set('OverallVehMilesPerGallon',formRepeat1.item.OverallVehMilesPerGallon.value)">Step 3</button>
                        <div class="d-flex"> 

Ok, now can you show this part:

The code/expression on “Estimated vehicle miles per gallon”

@Apple

   <div class="d-flex flex-row align-items-center">
                                <h6 class="cal2 cal6">Total amount of miles driven per year</h6>
                                <p class="cal2 cal7">{{session1.data.value.OverallVehMilesPerGallon}}</p>
                            </div>
                            <div class="d-flex flex-row align-items-center">
                                <h6 class="cal2 cal6">Estimated vehicle miles per gallon</h6>
                                <p class="cal2 cal7">{{session1.data.OverallVehMilesPerGallon}}</p>
                            </div>

here is how the session manager is set up

What’s the content of in your browser console:

dmx.app.data.session1.data.value.OverallVehMilesPerGallon
dmx.app.data.session1.data.OverallVehMilesPerGallon

@Apple

the way I have it set up right now, it will not place the values into the session manager.

see the video

they only way I can get anything from the repeat form to show up in the session manager is to set the session to Items. See the video. But when I do that I cannot just grab the value that is needed.

If I do items it is sending over everything, just too much info.

This kind of exceeds my front-end knowledge, I’m as lost as you :frowning:

man this can be so frustrating at times buddy. Man, I am so close.

As always thanks for your help!

Last try, .flatten(‘value’):

   <div class="d-flex flex-row align-items-center">
                                <h6 class="cal2 cal6">Total amount of miles driven per year</h6>
                                <p class="cal2 cal7">{{session1.data.value.OverallVehMilesPerGallon.flatten('value')}}</p>
                            </div>
                            <div class="d-flex flex-row align-items-center">
                                <h6 class="cal2 cal6">Estimated vehicle miles per gallon</h6>
                                <p class="cal2 cal7">{{session1.data.OverallVehMilesPerGallon.flatten('value')}}</p>
                            </div>

Probably won’t work, but session1.data.value.OverallVehMilesPerGallon seems to be an array, so you need to merge the values of each one? Unsure of the exact syntax

You’d need to play a lot with dmx.parse() to evaluate the expressions till you get them right

tried it and it didn’t work but I get what you are going for.

Ill keep playing with it. is there are reference guide on DMX parse?

Try this:

<div class="d-flex flex-row align-items-center">
    <h6 class="cal2 cal6">Total amount of miles driven per year</h6>
    <p class="cal2 cal7">{{session1.data.value.OverallVehMilesPerGallon[0].$value}}</p>
</div>
<div class="d-flex flex-row align-items-center">
    <h6 class="cal2 cal6">Estimated vehicle miles per gallon</h6>
    <p class="cal2 cal7">{{session1.data.value.OverallVehMilesPerGallon[1].$value}}</p>
</div>

The first value will show the overall vehicle miles per galon of the 1st vehicle. The second value will show for the 2nd vehicle. This is just to test if it works

But I have a feeling this is sort of a hacky way you’re doing the insertion into the session data, it might break if Wappler changes something

Regarding dmx.parse I guess you’ll have to search the forum to see random posts mentioning it

nope, Should I be pulling the data into the backend and then once all the data is captured have an API call happen that then send the data and then I display it? I was trying to avoid any use of another database. But if its Hacky I must be approaching this in the wrong way.

Im on my one on this one buddy, there is nothing on the forms that speak to repeat forms and session manager pull info.

New try, the first number must show:

<div class="d-flex flex-row align-items-center">
    <h6 class="cal2 cal6">Total amount of miles driven per year</h6>
    <p class="cal2 cal7">{{session1.data.value.OverallVehMilesDrivenPerYear[0].$value}}</p>
</div>
<div class="d-flex flex-row align-items-center">
    <h6 class="cal2 cal6">Estimated vehicle miles per gallon</h6>
    <p class="cal2 cal7">{{session1.data.value.OverallVehMilesPerGallon[1].$value}}</p>
</div>

Does it show? If it doesn’t show replace $value with value

nope, weird. I did both and the info shows up in the session manager but will not show on the details page.

@Teodor your turn

@ryanmorrow np, good luck :slight_smile:

@Apple thanks for your help my friend!

Please! anyone that could give me some insight to this issue… It would be greatly appreciated

@Teodor @ben @Hyperbytes