# Item type specific choices?

**URL:** <https://community.glideapps.com/t/item-type-specific-choices/67218>\
**Category:** Ask for Help\
**Created:** [October 23, 2023, 1:13pm UTC](https://community.glideapps.com/t/item-type-specific-choices/67218 "2023-10-23T13:13:12Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ralf\_Westphal](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/ralf_westphal/32/61695_2.png) [@Ralf\_Westphal](https://community.glideapps.com/u/Ralf_Westphal)\
**Post date:** [October 23, 2023, 1:13pm UTC](https://community.glideapps.com/t/item-type-specific-choices/67218/1 "2023-10-23T13:13:12Z")

</div>

SOLVED! See below for my own reply.

I’d like to implement the following:

Imagine a shopping cart. I add a product from another table, set the quantity, and then select a “model” from a drop down menu (choice). The models I can select of course depend on the product I selected for the shopping cart item, eg

- product “t-shirt”: models are “small”, “medium”, “large”
- product “pen”: models are “red”, “green”, “blue”

All products can define models.

But how to do that in the most easy way? I thought I could let the “product manager” enter the models as a comma separated list in the product, split the list up into an array an base a choice on that. But that does not seem to work; the array column of the table is not offered as a base for the choice.

Am I doing sth wrong?

Or do I really need to go through a separate table where the models are registered for the products, e.g. with columns (product ID, model):

- prod1, small
- prod1, medium
- prod1, large
- prod2, red
- prod2, green
- prod2, blue

---

<div class="post-metadata">

**Author:** ![Ralf\_Westphal](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/ralf_westphal/32/61695_2.png) [@Ralf\_Westphal](https://community.glideapps.com/u/Ralf_Westphal)\
**Post date:** [October 23, 2023, 3:35pm UTC](https://community.glideapps.com/t/item-type-specific-choices/67218/2 "2023-10-23T15:35:43Z")

</div>

Here is my solution:

What I forgot to mention but made the solution quite straightforward: I’m using a custom form for adding/editing a cart item.

Based on that the solution is looking like this:

- There is a PRODUCTS table to select the product for a cart item from. In the PRODUCTS table the models are entered as a comma separated list into a column “models”.

- There is a ITEMS table for the cart items. In that table there is a “model” column. Not that relevant for the solution, though.

- There is a ITEMS\_FORM table with just 1 row to be bound to the custom form to add/enter a cart item. This table there is a relation to the PRODUCTS table. And a lookup which pulls the value from the “models” column of the selected product. This is, where the fun starts.

In the ITEMS\_FORM table there is also a split text column “models\_split” which separates the model labels into an array.

The solution starts with yet another table I call MODELS. It has as many rows (!) as I think there can be models of a product, eg 10.

Each row has an “index” starting from 0 (up to eg 9).

Also in the MODELS table there is a single value column “models\_split\_single” to select the first (and only) record from the ITEMS\_FORMS table. From that - which contains the current item visible in the custom form - the “models\_split” value is grabbed.

And finally there is a second column in MODELS - “model name” - which is another single value type column, but this one picks a single value from the start (!) of the “models\_split\_single” column. As the index the “index” column’s value is used.

That way, each row in MODELS contains a different value from the “models” column of the product selected for the current item.

The MODELS table can easily be bound to a choice component on the custom form which then stores the selected value in its “model” column which mirrors the “model” column in ITEMS (to which the ITEMS\_FORM values are written using a custom action).

This solution was inspired by posts from @Darren_Murphy and @Robert_Petitto. Thanks!

---

<div class="post-metadata">

**Author:** ![Darren\_Murphy](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/darren_murphy/32/47326_2.png) [@Darren\_Murphy](https://community.glideapps.com/u/Darren_Murphy)\
**Post date:** [October 23, 2023, 4:02pm UTC](https://community.glideapps.com/t/item-type-specific-choices/67218/3 "2023-10-23T16:02:59Z")

</div>

You’re getting good at this, Ralf 🙂

---

<div class="post-metadata">

**Author:** ![system](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/system/32/53398_2.png) [@system](https://community.glideapps.com/u/system)\
**Post date:** [October 30, 2023, 4:03pm UTC](https://community.glideapps.com/t/item-type-specific-choices/67218/4 "2023-10-30T16:03:37Z")

</div>

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