SilverFox
SilverFox

Reputation: 41

Dropdown Widget and Related Model

I have two models, Country and City and a one-to-many relationship between them. One country can have many cities and a city can only have one country. App Maker generates a Country_fk field in the City model.

Now when I create a Create form and drop a form bound to the City model and include the related Country field App Maker creates a dropdown with the following:

options: @datasources.Country.items

value: @datasource.item.Country

Which, if I compare it with some example apps looks absolutely fine. However, I only get the Id of the related Country field not the country name field.

This has happened so many times with different models. I did once manage to create a relationship that worked, and it used the same datasource options and value values, but I can't for the life of me see why something so simple as this is so hard to do. it is so basic newbie stuff I'm beginning to give up on App maker.

Upvotes: 0

Views: 70

Answers (2)

Citizen Coder
Citizen Coder

Reputation: 11

You need to make the required field the 'Display Name' in the relevant model. Once you do this it will display as you want 👍

Upvotes: 0

Morfinismo
Morfinismo

Reputation: 5253

You can use a little bit of help from the official documentation.

When you create a model, you can select the default display field. App Maker uses the default display field when it refers to a record in the model. A display field is commonly used for widgets that select a record, such as dropdowns.

Go to your model and make sure you select the proper display field. Something similar like in the image below.

enter image description here

Upvotes: 1

Related Questions