Button to update a field of a record in the database

Hi. I’m in need of some assistance.

I need to have a sign-up flow over multiple pages and, just to simplify the following example, let us work with the following:

My User collection has the following fields:
-> Name
-> Email ID
-> Password
-> Gender

The Gender is a separate collection, consisting of “Male” and “Female”, which is linked to this through a relationship so that the only options I receive on the User record under ‘Gender’ are these two. If there is an alternative to this that would solve or play a part in solving my issue, I could change this system.

I have a sign-up page in the start which collects the Name, Email ID and Password information. I do not, however, want to collect the Gender information here. I would, instead, like to take that information on the next page which I’m guessing can be done by taking inputs of only these three fields in the first page and, in the next page, add another form to collect just the gender information and update it into the logged in user’s record.

However, I also require my collection of the Gender information to be in, not a dropdown format, but, a format which comprises of two buttons, one labelled Male and the other labelled Female, where, if the first button is clicked, the logged in user’s record’s Gender property is automatically updated as “Male” and if the second button is clicked, “Female”.

I tried creating this. However, the Gender property does not seem to be updating despite several different approaches to this problem. In fact, I tried using a separate dropdown component, which offered only “Male” & “Female” (derived from the Gender collection), to update the user record, as a test. This, too, did not seem to work. The only solution I currently see is to put a form component to get this information, which is not what I’m hoping to achieve.

Is there a solution which could get me the result I’m looking for or would I have no other option for now but to stick with the form format?

Thanks in advance.

To do this, I would add a button to your 2nd screen. Make it a custom list of genders, and then add an action to the button that updates the current user and sets their gender to the current gender.

Hi, Ben. Thanks for your response. I did try that solution where, upon clicking the ‘Next’ button on my Welcome Screen, it creates a new user with default values set for each of its parameters which I can update with this button system from each further page. However, for some reason, either the new user does not get created (for which I tried manually creating a user record to get the buttons to update the parameters) or it just does not seem to update the fields. I did, however, notice a pattern in this where most of the fields that do not get updated are those which our linked to the User collection via a relationship. Although the options and the value to be inputted by the button are the same (for example, for the ‘Gender’ parameter, the options are “Male” and “Female” and the button inputs “Male”), it still refuses to input this data into the User collection’s parameter.

I also tried using a dropdown with the same options pulled from the original collection (by the same options, I mean “Male” and “Female”, in this example) and directly adding it into the User collection’s Gender parameter. This, too, does not seem to work.

Could this be a feature that is yet to come into Adalo or some sort of bug, perhaps?

Hi @tesla,

Why wouldn’t you just put a 2 static buttons (“Male” and “Female”) on the 2nd screen, and add an action “Update” for Logged-In User for each button, putting text “Male” / “Female” in the appropriate User’s field?
External collection for Male/Female selection makes sense only if you need a dropdown, otherwise it’s overkill, IMHO.

BR, Victor

Hi, Victor.

I did try that but that, too, did not seem to work.

However, I’ve found the solution - and learnt an important lesson in the process. A button cannot be used to update data in the Adalo database. Only a form can do that.

As a solution, I, therefore, used a form with no visible fields (which means, on the front-end, you would see nothing but the submit button) and, in the ‘Set Automatically’ section under ‘Fields’, I added the update that was required to the database if it were clicked.

For example, if I needed Button 1 to update the Gender of a user as “Male” and Button 2 to update it as “Female”, I would add two forms and remove the visible fields, leaving just a submit button on both forms, and, in the ‘Set Automatically’ section under ‘Fields’, I would set the Gender parameter’s value as “Male” in the first form and “Female” in the second. Therefore, if you click the Submit button of the first form, it would go ahead and update the parameter value of the User’s ‘Gender’ parameter as “Male” and if you clicked the Submit button of the second form, it would update it as “Female”.

Post this, it’s just about playing with the UI design of the form’s submit button to make it look the way you want it to look.

I really appreciate all the help I’ve received. Thank you so much for all the assistance :smiley:

1 Like

@tesla I’m glad you got it working but the information above is not correct.

You ARE able to update data in a collection with a button. Within the options of actions for buttons are “Create”, “Update” & “Delete”. All of which directly manipulate available data within Adalo.

1 Like

Hi, Colin. Thanks for the response. I agree that buttons do possess the functionality to alter databases via the ‘Create’, ‘Update’ & ‘Delete’ options. However, it refused to work despite several different attempts. It may have been the case that I must have used it incorrectly but I felt I was able to achieve much more through the forms (and, frankly, quite easily, as well) than through a button.

I put it across as a solution to anyone who may be facing the same issue as me but you may be right on it not being the only solution to the problem.

Thanks for pointing it out.
~ T

1 Like

Hi @tesla,

In my opinion you were missing something when creating your signup routine. May be you tried to create user record on your first screen, instead of doing “More…” → “User Login” → “Sign Up”?
I’ve made a video of multistep signup - please see it here. A bit long (8 mins), but explains all the process and shows the result.

If you need the app itself - please let me know.

Best, Victor.
Video:

1 Like

Hi, Victor.

This video makes perfect sense. I was able to solve my issue a few days back by pushing the sign-up screen that collects the Email, Name and Password details to the front of my sign-up flow instead of keeping it in the last and having placeholder data for it until the user reached that part of the flow. I realised that a lot of my problems were solved through this and noticed that, in the video you sent, the first page did collect the Name, Email & Password, as I made mine to, in the end.

Thank you so much for taking the time to help out and create an entire video for this.

Warm Regards,
~T

1 Like

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.