Dropdown value to database

I got a form in a table that is submitted on blur of a select input/dropdown menu from which a category can be selected from a database list:

I get an error from the SC action that there is no value to be updated:
message: "Empty .update() call detected! Update data does not contain any values to update. This will result in a faulty query.

I can’t figure out how to set the selected dropdown option as a value for the form and send it to the SC action on submission. How can I achieve that?

I am just guessing here … perhaps you haven’t set your key in your update server connect action? Again, just a guess. Where do you see this error message?

What exactly are you trying to achieve?

I want to show the current database value in the dropdown and change it in the database through the SC action when another value is selected. I followed your tutorial, but can’t get it to work.

So you are trying to filter a database query using a dropdown?

No that’s not what I am trying to do.
The options in the dropdown to choose from are text values from another database table. When one of these options is selected I want to insert that text value in another database table field (product field, hence the (hidden) product_id field to set as a condition) using the sc form.

So when a value is selected in a dropdown you want to run any action like insert or update, is that right? How do you run it - is it a whole form that needs to be submitted or is it anything else?

Indeed. It’s a form with a hidden product_id field and the dropdown select input. The sc contains a database update action that sets the dropdown selected value in a database field.
Is essence the problem seems to be that I can’t get the (new) selected dropdown value submitted through the form to that sc action.

Why don’t you submit the server connect form on dynamic events > change of the dropdown?

Sorry for the late response, had to call it a day yesterday night :slight_smile:

image

You mean like this? I tried that too, with form submit as the selected action to perform:
image

Although it is for sure a better way to trigger the form submit, I still get this status 500 error in the console then:
message: "Empty .update() call detected! Update data does not contain any values to update. This will result in a faulty query. Table: products. Columns: product_category.

I thought the reason for this error might be an empty category field in the db and it can’t be updated because of that, but I just checked and the same error occurs with a record where the field had a value.

I think the problem is that when a dropdown value is selected I don’t have the setup right to send that new value to the sc action when the form is submitted. Can’t get that part fixed however. Hope you can help :slight_smile:

Well, looking at your error message you are sending an empty value to the update record. Please check what exactly do you send to the server action and how. Also check if the update step and post vars are properly setup.

That’s exactly what I think the problem is. This is the update step I got setup:

I think the select_prod_category value is empty indeed, but I can’t find a way to get the newly selected value from the dropdown in there :nerd_face:

Which value is sent to the server action? I can’t figure it out.
image

This is the data source:
image

And both Test Field & Vlua Field are populated with this:
image

Try to disable the update step and add a setvalue step instead. Use the POST value there as its value, enable the output option and see the response from the server action - do you see the dropdown value assigned to the setvalue step?

Thanks Teodor, did so and it’s only th product_id in the POST values:

  1. debug_value: {prod_category_id: “296”}
    1. prod_category_id: “296”

So the selected dropdown value is indeed not transfered to the server action.

Just sending you the raw code, maybe you can locate the issue more easily there:

<form id="edit_prod_category" method="post" is="dmx-serverconnect-form" action="../api/edit_prod_category">
	<input type="hidden" class="form-control" id="inp_prod_category_id" name="prod_category_id" aria-describedby="input1_help" dmx-bind:value="product_id">
	<select id="select_prod_category" class="form-control" dmx-bind:options="get_categories.data.query_categories" optiontext="category_name" optionvalue="category_name" dmx-on:changed="edit_prod_category.submit()" dmx-bind:value="product_category">
	</select>
</form>

Hi @Teodor,
Still couldn’t get this to work. Got an idea about why it’s not working for me? Thanks in advance.

Aloha Emiel,

Please use with caution. I am a newbie & this is my very first attempt to give back to the Wappler community. I just configured a select for the very first time yesterday and it functioned correctly the first time (I just Love Wappler) giving me the confidence to share. I was assisted by posts in the community on “Selects (or dropdowns)” from @psweb @Hyperbytes and of course @Teodor

My use case was to populate a dropdown in a form with several Blog Post Categories from a Query. Then on submit, pass the dropdowns “Selected Value” to a database. I have assembled several screen shots with the configuration that was successful for me. Please let me know your thoughts when you can.

Good Luck! :rocket:

2 Likes