Limit in App Builder "Choice" element

Please fill in the questionnaire below.

Help Questionnaire

Self-Hosted Installation and Setup Questions

How have you self-hosted Baserow.

Official Docker image with separate postgres db

Which version of Baserow are you using.

1.29.0

Describe the problem

Describe, step by step, how to reproduce the error or problem you are encountering.

Hi team, I’m coming across a strange issue and I"m not sure if it is a config problem on my part of some hard limit.

I have 2 tables.

  • One is called “Bookings”
  • The other is “Locations”.

I have created a link between both tables. The idea is to, when I create a new record in “Bookings”, choose from one of the “Locations”.

  • The bookings table has a linked field called “Location”

When I’m building the front end in the Application Builder, I’m creating a form on my page so the user can make changes to an existing entry in the “Bookings” table.

I have 2 data sources in my page:

  • Get single row - Bookings
  • List multiple rows - Locations
    Neither of these have a filter on them

I create my form and add a form with “Choice” element.

  • “Default value” and “Placeholder” are both set to "Data source > single-booking > Location > [All] > value
  • “Optional values” is set to "Data source > Locations > [All] > LOCATION

When I test this on my front end, it works, but the drop-down only displays 20 values to choose from. My Locations table has about 96 entries. So I can’t choose the majority of them.

I tried to work around this by choosing the element “Record Selector” instead. This fixes the 1st problem - in that it now shows all 96 entries. However, it introduces a 2nd problem.

When I have a form with a “Record Selector” element, I get an error submitting the form if I don’t select and choose a value. So for example, if I have a form with 10 fields, and “Location” is one of them, I have to drop down “Location” and choose an option, even if it is the same option that is already displayed (ie because I have set the “Default value” and the “Placeholder”. This doesn’t happen with a “Choice” element.

I’d appreciate any assistance or guidance. Thanks in advance!

Hey @spook, here’s an explanation of the choice element limitation:

Regarding the record selector element, I’ve asked my colleague to check the question. :slightly_smiling_face:

Thank you for your fast reply! The record selector looks like what I need. Let me know if you need more details on the record selector issue.

Hello, yes the record selector should work for the use case what you describe.
Is this field marked as “required”?

Just to confirm, are these the steps to reproduce this problem?

  1. Create a record selector and connect to Location table data source
  2. You set the default value of the record selector to the Booking > Location
  3. When you try to submit the form it still requires to manually select an option from location?

Thanks,
Afonso

Hi Afonso. Those steps are correct and I don’t choose “required”. I created a new page with only a form on it to confirm this was happening and was able to reproduce the issue

Here is a screenshot of the settings for the Record selector:

And the Submit button:

And my test page:

image

If I click the “Submit” button without making a selection, I get the “invalid form” error. If I choose a drop-down (even if it is the same option), I can submit the form successfully.

Hi team,

Just wondering if you have an update on this?

Cheers.

I’ve been playing with this today for the first time, and might have some thoughts that might help (though… I may not understand it all yet).

If you use the Choice object in your form, you will load the choice options for the field, not the items in the field itself, which are not stored in the table as far as I can see (its probably in a hidden linked table maybe? You can kind of see them using the API browser.) So you can’t use the Data object to populate (and thus filter) these choices.

The Record Selector is different… its loading the values from the field itself, which means you can use the Data object to load a table, and display a field in the selector. And therefore you can filter the data object to limit the list of options returned.

So this means you kind of need to create reference tables for the values you want to use in your Record Selector (unless you can pull a full set of ALL options from a field in an existing table), and query the reference table to populate the “choices”. I tried this and got it working.

The trick is, instead of having a Single Select field in the database, you need to put in a Linked to Table field to the reference table. Here are some pics.

This is the Record Selector in the form, and the values are filtered by the Data object in this case, there are more than two in the reference table.
image

In the Data object you can see the filter applied.
image

This is the Record Selector form value that you put into your forms event. Note that the value is a number, the row number of the reference table is what will get populated here.
image

In the database I have three fields to demonstrate what happens.
image
image

  • The first is a Single Select field. If I try to put the Record Lookup value here it will fail, as it actually needs to store the hidden rowid of the choice I believe, which is hard to get. (Even using the API lookup I found this value I thought, but still couldn’t get it to accept it as a hard coded value. Not sure why.)
  • The second is just a text field that stores the result of the Record Lookup purely so you can see it’s just a number, the rowid of the reference table.
  • The third is a Link to Table field, pointing to the reference table that holds the values for this list of options.

The actual reference table looks like this… and you can see its linked to one record already.
image

Now, this is more work to do, but… it does provide a little more flexibility (eg. you can sort your Record Lookup) and most importantly the ability to filter a set of choices for your form.
Hopefully this filtering functionality will be build directly into the Single Select object soon, as its already build into the database form builder I noticed. :slight_smile:

Now, if I have missed something important that negates the need to do all this, I am sorry, still very much learning the basics, but I thought it might help. I really appreciate the comments other have posted that have helped me a heaps. :green_heart:

Actually I just found the same thing is happening for me.
image

Option in the Record Selector is not set to default. (Shown in heading so I know its getting the right value. (using “value” in the heading.)
image

I also get an error when I submit the form (unless I select something from the Record Selector). Curiously, if I set the field to Required, it won’t let you submit the form (which is expected), and even if I then select an option, it still won’t submit the form. If I select the option before submitting the form. Then it works and saves without error. :thinking:

Anyway, you can probably ignore the rest of my ramble above, except to confirm if its correct - in which case it might be helpful for others new to the app builder. :upside_down_face:

Thanks @DataGecko . It’s good to know I’m not the only one seeing this issue. I’m about to upgrade to 1.30. I’ll see if the issue is still present and report back.

Can confirm that this still seems to be an issue in 1.30. The way around it at this point is just to have a button for each Record Selector on the page. It’s a but clunky, but for now it works.

Maybe I missed it, but how are you setting this up? What is each button doing?

Got another issue with Record Selectors. This time its failing when I click on it with this error.


I really hope the issues with record selectors can be resolved as they seem like just the solution we need. :slight_smile:

The above error seems to be resolved when I limited myself to one form on the page. Is that a known limitation? It still doesn’t populate with the default value though, so you get an error if you don’t select an item from the Record Selector.
I have one page with one form, two record selectors, four choice selectors and a text entry box, and submitting the form works if I populate the two record selectors now - if I don’t it throws the error.

I have another page that I am still running into issues with though, and will try to determine if its something of a similar issue.

Might be worth starting anew topic for the other issue as to not “muddy the waters”. Having said that, I still am experiencing the original issue and would love a solution if possible @afonso or @olgatrykush. Cheers.

Hi @spook, I’ve asked the Application Builder team to look into this issue. :blush:

Either @picklepete or @jrmi will respond to you soon.

1 Like

Thanks Olga. That’s awesome!

Staying focused on your issue spook, I was playing a little more and managed to get the Record Selector to work for me (with one small issue still). For the default value instead of All I used 0.
image
Now maybe someone can explain precisely the difference between All and 0, 1, 2 etc. But, it did seem to work, its saved the record and displayed it again after I refreshed the page. The only bit that was strange was the little blue cycles kept spinning when the page first loads until I click on an entry. Other than that it seems to be working ok. :thinking:

1 Like

This seems to have fixed itself over night as its not doing it now. So, for me, the Record Selector seems to be working correctly now. :blush:

Hi @spook,

Apologies for the delayed reply (bad timing :sweat_smile:) and thank you for your patience.

As you rightly guessed, in your case, it’s better to use the record selector since it is specifically designed to display a list of options from a (potentially filtered) paginated data source.

I reproduced your bug regarding the default value not being set in v1.30, and this issue will be fixed in the next release (v1.31).

However, I noticed you were using the value property as the default value for the record selector. As @DataGecko mentioned (thanks for your great contribution to the discussion), the record selector is designed to work with the internal row ID of the record. In your case, the default value formula should be something like Data source > single-booking > Location > [All] > id. This approach selects all values of this multi-valued field since link row fields are multi-valued by default. Consequently, you should also check the Allow multiple values option to select these multiple values.

If you want to select only one value (e.g., the first), use the formula:
Data source > single-booking > Location > 0 > id. In this case, it will use only the first value, and you don’t need to enable the multiple values option.

Also, the placeholder is intended to prompt the user to input a value when no value is selected; it is not meant to serve as the default value. This is why the form considers it empty when you try to submit it even if you have the feeling the value is there. If the record selector had been working correctly from the start, this issue probably wouldn’t have occurred.

We definitely need to improve the documentation for this element as it is currently incomplete.

I hope this resolves your issues and answers your questions. Let me know if you need further clarification.

1 Like