Form selection dropdown not showing database value

Wappler Version : 4.0.4
Operating System : Windows 10
Server Model: nodejs bootstrap 5
Database Type: MariaDB
Hosting Type: local

Expected behavior

What do you think should happen?
I have a master / details setup where I click in a row in a master list table and through data details display the detail record in a form.
In this form I have a dropdown select input, which is populated from a lookup table, which works fine.
However when I select my master record it is not displaying the associated value in the drop down as stored in DB master table as a FK, whereas it should display.

If I replace the dropdown value field from the “ID” to the “text” value then it works fine, but then the “text” value is sent to the backend, meaning another lookup is required to obtain the ID

Maybe my understanding is wrong, but if so then I am lost.

  1. This is the data source that populates the dropdown for selection

  2. This is the dropdown selected text field from the data source selected drop down row

  3. This is the dropdown selected unique ID, from the data source selected drop down row and is what should be sent back to server side

  4. This is the data details selected text value representing what is already saved in the db

So the value from 4) is not displaying with setup as below

 <select id="select1" class="form-select" 
   dmx-bind:options="scn_menu_cat_get.data.qryGetMenuCategories" 
   dmx-bind:value="dd_menu_item_details.data.category" 
   name="select1" 
   optionvalue="menu_cat_id" 
   optiontext="category">
</select>

With the below config the value of 4) is displaying correctly in drop down when master record row is clicked in table

<select id="select1" class="form-select" 
   dmx-bind:options="scn_menu_cat_get.data.qryGetMenuCategories" 
   dmx-bind:value="dd_menu_item_details.data.category" 
   name="select1" 
   optiontext="category" 
   optionvalue="category">
</select>

The selected value in select menu must match a value of some of the select options, not its text.
So if your select option value is ID, the selected value must also pass an ID.

If you mean the following then I understand
Each dropdown has 1 or many options
Each option consists of a text / value pair

I can see the option text in dropdown,
When selecting an option the text is displayed, but the value is sent to backend on submit
This is what my 1st screenshot shows and I believe to be correct.

However when selecting a details record the drop down always shows 1st dropdown option entry text irrespective of what option id was saved in db with the details record
In other words the drop down is not synced with saved data (the lookup is fine)

My 2nd screenshot I believe to be wrong, but this way the drop down is synced for pre existing records.

I am confused by your explanation.

From your first post I understand that the “selected value” works for you when the option value uses the category binding, not when having the menu_cat_id Is that correct?

If that’s correct, then you just send a wrong value to the “selected value” option.

You should be sending the category id with this:

dmx-bind:value="dd_menu_item_details.data.category

not the category name… The select won’t work when its option value is the category ID and you send the category name in the selected value.

Apologies for confusing you Teodor, in my 1st post I was trying to convey 3 things:

  1. Based on my understanding was seeking confirmation that my setup in 1st screenshot is correct
  2. If my understanding is correct then I am having an issue 1 where category is not displayed on details record through data details binding
  3. If 2nd screen shot setup is correct then it solves issue 1, but creates another issue where category ID is not sent to backend

I got it to work, I finally understood what you meant, and changed the binding value to the following, and all works as expected now. Thank you for your patience and assistance.

dmx-bind:value="dd_menu_item_details.data.menu_cat_id