Database UPDATE inside a Modal

Has anyone had any issues with Database UPDATE inside a Modal? i just can’t get it to update the MySQL DB. There are no errors being thrown in either the browser or Apache error log files.

I am sure it is something simple.

Having the same problem with both Wappler 1.7.1 and 1.7.2 so it has nothing to do with Wappler update.

What exactly are the issues you have with the dB update? Does the form submits to the server action? Does it includes all the data? Any errors in the server action - you can check all this in the devtools

I’ll give you my experience in case it applies to you.

  • I create an Update action step in server connect.
  • Looking at the suggested post values, I noticed all lower-case while the database entries contained camel-case.
  • Using the Generator to create the form in the modal, I noticed that the input names were all in camel-case
  • So now I have camel-case posted values when lowercase values are expected.

image

The solution is to have both the posted values and expected values the same.

@ben Thanks for the suggestion, I capitalised the “ID” in three instances as you suggested but made no difference. Always worth a go. I have included my action in case you see anything wrong.

Hi @George, thanks for the questions :smile: and so here are some screenshots. I suspect that the form is not getting submitted to the server action as shown by the last screenshot (I think that’s what it shows). There are no errors and I seem to be getting status 200 (OK) but no Preview/Response from user_update.php (which is the server action file).

image

image

I am not 100% knowledgeable with DevTools and so please feel free to treat me like a novice. This is all on my local machine. Obviously if you need any further info or screenshots then please ask/guide me as to what you want. Cheers

I think that you will find the lower-case still present under Globals $_POST. I am working on a project at the moment.

To make sure that the name attribute in the form has the same value - lowercase.

@ben do you not sleep?

I should ask you that. We are 11 hours in front of you guys. That makes it half four in our world (Oz)

Ah, forgot about that. Been up since 3, couldn’t sleep, still dark outside :tired_face:

And cold no doubt. 28C here! Shouldn’t be sitting inside.

1 Like

Back to the issue, I had the same symptoms, the form submitted successfully, nice little notification telling me so, yet no change in the database. I changed everything to lower case and the result felt like I was climaxing.

You are right, still lowercase in the Globals, how can I update that?

image

No need to change the values in the database, just under the Server Actions and in your form.

Yaay! Thanks @Ben, I have changed all database fields to lowercase, then did a search and replace on all “_ID” to make them all “_id” (which was the only capitalisation I had) on the php files and in all the dmxConnect files. Once EVERYTHING to do with database fields names were lowercase I then tested and voila! It worked as expected. I am a happy bunny again :smile:

image

image

@George is this expected?
Should everything related to database field names be lowercase?
If so, then I think you should advise people.
If not, then do you need to make a change to the system so as not to be case sensitive?

It doesn’t need to be all lowercase for POST vars. Lowercase is only required for GET vars, but server connect automatically makes them lowercase when required.
I think you just had different text case somewhere that didn’t match.

1 Like

I don’t think that this is ‘normal’. I still keep camel-case in my database and I think that the $_POST values should reflect that.

It took me the best part of a day to find the problem which surfaced in version 1.7.1 and now in version 1.7.2.

At least it is working and that is the main thing.

Thanks @Teodor, you may well be right with a mismatch somewhere. It is no hardship for me to keep everything lowercase from now on, it will keep things simple.

And thanks @ben for pointing me in the right direction. As Teodor says, it was probably a mismatch rather than a need for lowercase. Anyway, thanks again and now for some breakfast. 6:55am it’s a nice warm 3°C at the moment and there’s no frost this morning :smile:

1 Like