Default value for Choice component in Pages

Hi,

I am sure many have asked for this, but I don’t see “Default Value” field in Choice component in Pages (which is there in Glide Apps).

Any idea or any workaround to get this work?

The only way around is use a custom form and set a value to the column holding the choice before users enter the “form”.

1 Like

Thanks @ThinhDinh. I will have a look at it.

1 Like

Just checking if there is a solution for this. TQ


3 Likes

got it. has to be within a form.
TQ

1 Like

Not sure why it is limited to be within a form. If a default value was always allowed it would be better in my opinion. When I do not want a default value I will not set one.

Probably an easy fix - just do not check the component is on a form

But if you are not in a form, then it’s pulling data directly from a column in a specific row. Those components are always connected to existing data.

In a form, the components are not connected to any row, so having a default option always makes sense, because you always know it starting from null.

I’m sure there’s a few use cases out there, but I think people don’t consider the risk of overwriting data unknowingly if the default value kicks in and overwrites data that was previously set.

Okay that makes sense.

What I was not thinking about is that the form is only connected to the data when it actually writes on the submit whereas a screen is connected all the time.

I probably have some misunderstanding here about forms. So what I have been doing is making my own form where the data I want to get I specify a user column and put the data in there and then have a button copy the data to where I want it. I did this because I thought there is only one form per table. I have different sections in my app that need to edit different pieces of the data in a “row” so I needed more than 1 form.

Am I correct that there is only one form to a table?

I guess I could separate the data to different tables and then join them and then I could have more than one form.

Regarding custom forms, which it appears you are using…The method that most of use use is to use a custom action that first clears or sets defaults to certain users specific columns before opening the form. I have a custom form that I use for both adding new rows as well as editing existing rows. If I have the mode set to Edit, my custom action retrieves values from a row and fills the user specific columns before opening the custom form. When I’m done editing, I have a custom action on a button that checks the mode and either adds a new row, or updates the existing row based on that mode.

To first clarify, there are 3 types of native forms in Glide, or at least there used to be. There’s the Add Form, the Edit form, and just a regular Form (not specifically linked to any table). You can have several different native regular Forms that Add rows to the same table and have independent designs. However the Add Form and Edit Form design is specifically linked to a table…but there are a few ways to work around that limitation with some visibility conditions in the same form.

So to answer your question, no, you are not necessarily limited to one form per table. Just depends on how you have it all set up.

I don’t think you would have to go that extreme.

2 Likes

Wish I would have thought of using an edit/add flag for my custom forms, would have saved copying in a bunch of instances. Thanks for the idea and help.

1 Like