Text box for adding items into a dropdown without attribute

I work on a registration form. User needs to be able to enter his favourite foods. For that reason, I would need to let him add them one by one to list and then save all of them to table/domain object "Foods" with the user ID. My idea of the form is like this: User types in the checkbox and clicks on 'Add'. The string appears in the list. He repeats as many times as needed. But Text box seems to need attribude always and there is also no list component, how should I resolve this? Also it seems I cannot have two domains (DB tables) in one form, which is an issue.
1 answers

The form is based on entity 'User'. The entity 'Food' does not need a userid attribuut. In Mendix this is done with an association. Either 'Food' is prefilled and user can select from a list, in that case the association is a reference set and use a 'reference set selector' widget to add one-or more favorite foods.

Other option is 'Food' a private list per user with user added data. In that case the Food entity has a association type 'reference'. Add a datagrid on the user form and select the association Food_User. Right click on the 'New' button and select 'Generate form'. User has to press 'New' to add a favorite food.

To get exactly your form, create an attribute 'FoodToAdd' on 'Account' or (better) your inherited user entity. Put it on your form and add a microflow button behind it with text 'Add' connect a microflow with that button and pass the account as parameter. In the microflow: create action with entity Food. Assign Account/FoodToAdd to Food/Name and Food_Account with Account. Clear the FoodToAdd attribute with refresh/don't save.