Problem with Multi Insert

Can’t seem to get a multi insert to work from as follows.

I have a repeat region that has two form fields inside.
These are multiplied by the number entered in the input field above it. ( ‘how many blocks’ shown below )

<input type="number" class="form-control" id="blocks" name="blocks" aria-describedby="howmanyblocks-label" placeholder="If yes how many Blocks" data-rule-number="" data-msg-number="Numeric values only please." dmx-bind:disabled="(splitBlock.value == 'No')" min="2" data-msg-min="A minimum of 2 blocks is required." required="" data-msg-required="Please specify how many blocks." dmx-bind:required="(splitBlock.value == 'Yes')" data-rule-min="2" max="10" data-rule-max="10" data-msg-max="A maximum of 10 blocks is permitted" dmx-on:updated="blocks.validate()">

Here’s the variable that has the value of the above input:

<dmx-value id="blockNumber" dmx-bind:value="rtmApplicationForm.blocks.value.toNumber()">

And here’s the repeat region:

<div role="group" class="row block-details" area-labelledby="block-label" is="dmx-repeat" id="blockRepeat" dmx-bind:repeat="blockNumber.value">

<div class="col-md-6">
<div class="form-group row">
    <label for="blockName1" id="block1-label" class="sr-only">Block 1 name</label>
    <div class="col-lg-6 col-xl-7">
        <input class="form-control name" name="blockName[]" dmx-bind:id="'block_name'+($index+1)" dmx-bind:name="'block_name'+($index+1)" aria-describedby="block1-label" required="" data-msg-required="Please specify the name of this block." dmx-bind:placeholder="'Name of block_'+($index+1)" dmx-bind:required="(splitBlock.value == 'Yes')">
    </div>
    <label for="blockNumbering1" id="numbering1-label" class="sr-only">Block 1 numbering</label>
    <div class="col-lg-6 col-xl-5">
        <input type="text" class="form-control" name="blockNumbering[]" dmx-bind:id="'block_numbering'+($index+1)" dmx-bind:name="'block_numbering'+($index+1)" aria-describedby="numbering1-label" dmx-bind:placeholder="'block_'+($index+1)+'Numbering i.e 1-9'" required="" data-msg-required="Please specify the numbering for this block." dmx-bind:required="blockName.value">
    </div>
</div>
</div>
</div>

Here’s screen shots showing set-ups

I am currently using the field values from the post data bindings for the insert properties. or do I use the bindings from the ‘record’ array further down the picker? ( See Video )

Can anyone see where i’m going wrong?
Thanks in advance!

Taking one step at a time, the code should look like

<div class="col-md-6">
    <div class="form-group row">
        <label dmx-bind:for="'blockName'+($index)" class="sr-only">Block {{$index+1}} name</label>
        <div class="col-lg-6 col-xl-7">
            <input class="form-control" name="blockName[]" dmx-bind:id="'blockName'+($index)" required="" data-msg-required="Please specify the name of this block." dmx-bind:placeholder="'Name of block_'+($index+1)" multiple="true">
        </div>
        <label dmx-bind:for="'blockNunmbering'+($index)" class="sr-only">Block {{$index+1}} numbering</label>
        <div class="col-lg-6 col-xl-5">
            <input type="text" class="form-control" name="blockNumbering[]" dmx-bind:id="'blockNumbering'+($index)" dmx-bind:placeholder="'block_'+($index+1)+'Numbering i.e 1-9'" required="" data-msg-required="Please specify the numbering for this block." multiple="true">
        </div>
    </div>
</div>

Where label for: should read the same as the input ID and name is an array.

Edit: Forgot to add multiple="true". Now rectified.

Why do you restrict the number of blocks to a minimum of 2? If there is just the one block then the repeat would get a value of one and the process is the same as for multiple blocks. No need for separate processes.

This section is for multi-blocks only. There is a question above that asks ‘Is the development split into self contained blocks’ there as radiogroup for this question with options ‘Yes’ or ‘No’. If No is selected then the multi-block section in question is hidden. If Yes is selected, then thee has to be a minimum of 2 blocks and a maximum of 10. It has to be separated this way because of the way data has to be entered into the DB for multi-blocks.

Ok. I do not have enough info about the app. But give it a thought. You could have the one process where you flag the ‘yes’ or ‘no’.

Then in the following:
image , I would put an ELSE statement instead of a ‘Condition’.

You should have a ‘database multiple insert’ under the ELSE statement. Edit: Sorry, just saw the different tables to record the data. Please ignore this.

Sorry to be pedantic, why do you have each of the steps marked as ‘output’? The ‘output’ is so that you can show the data on the client side. I do not think that this is required for all of the steps.

Edit: I think that I have the whole thing wrong. The way that you have set this up is not the normal way to insert multiple records. I will have to rethink the process.

May I ask, why are you putting each entry into a different table. Cannot you put a flag in the one database table that records the property number?

Thanks for your response @ben. Can you explain what the normal way of inserting multi records is? I thought that Repeat regions along with Multi inserts is correct.
Subsequently the database design was done this way to separate the different sections of the form, but that’s not my concern right now to change that.

What I think what you need is an owners table and a premises table

Owner Table
OwnerID
…other info

Premises Table
PremiseID
OwnerID
…other info

When you want to list the premises for an owner
select * from premises where ownerID

or a single query:
select premiseID from premises

Where does post.record come from this isn’t what you defined in the app connect side for either array

Maybe I’m missing something on im mobile right now

I appreciate your efforts @ben but I think you’re completely misunderstanding what I need to achieve here. To give you a bit of background…
This is a re-design project and the database is an existing database that has been in function for over 10 years and works absolutely fine.
the form in question has numerous sections which I am now structuring in a Multi-step form. this particular section is to determine how many blocks in the premises ( development ). If it is not a Multi-block then Block details section is not shown as explained previously. If it is Multi-block then the number of blocks has to be specified. it is this number that determines how many repeats are shown.

There are two input fields that are in the Repeat Region - Block name and Block numbering

This is because for every block there is we need the name and flat numbers in each of these blocks.

So my task in hand is to get these inserted in the database table which will be in a range of 2 -10 records inserted.

I hope this makes sense! :grimacing:

I would combine these 2 into one array using

dmx-bind:name="arraynamehere[{{$index}}][blockname]"

dmx-bind:name="arraynamehere[{{$index}}][blocknumbering]"

Which when reimported into server connect will now show a new array use this array in the repeat and the 2 values will be available

Just a little more detail on server connect side:
If you have the dynamic names like I showed you get this structure (my names are different because they reflect my inputs but there’s 2 values and a array name):

Using the array in the repeat expression:

We can now access both repeated values to include in the repeat:

Then mine is a update but you would have an insert with properties from the repeat:
Screenshot 2022-03-10 at 14.10.44

Hope this makes sense

Thanks for this @Sorry_Duh. I’ll take a closer look later and let you know how I get on.