A new setting on the ProductType form. This setting is not saved into the ProductType, it reflects the cardinality of the stores field.
If checked, cardinality is unlimited. If unchecked, cardinality is 1.
If cardinality is unlimited, and there is data in the field, the checkbox is disabled, to prevent data loss.

Comments

dbolinovski created an issue. See original summary.

dbolinovski’s picture

dbolinovski’s picture

Minor changes.

bojanz’s picture

Status: Active » Needs work

I realized changing the cardinality directly can't work because it's a field storage setting, which means that it is changed for all product types.

We'll need to store the setting inside the product type, then use it in the widget + implement a validator.
I'm going to commit #2556401: Add a custom widget for referencing stores first.

bojanz’s picture

Status: Needs work » Closed (won't fix)

Decided not to do this for now. It's not essential to our store use cases, so I want to give it time and see how people actually use stores in the wild.

The selection can easily be limited by a hook_field_widget_form_alter() that sets #multiple => FALSE on the entity_select element.
An additional validator can enforce the same thing on the API level.

Thank you for the exploratory work, dbolinovski.