Score:0

How to disable or remove entity references with unlimited cardinality once one entity reference is chosen

cn flag

I have a paragraphs field that references multiple entity references with unlimited cardinality. I want to disable or remove the other options once one of the entities is selected. The use case is for a card grid component, only one card type should be available for the grid, so on select I would like to get rid of the additional options. The card grid should essentially only allow for one type of entity reference but with unlimited cardinality for the select entity.

I've tried with no success using a custom form_alter and checking the $form_state, but I would ideally like a no code option if possible.

if(!empty($form_state['values']['field_select_card_type_blue_card_w_image_add_more'])) { unset( $form['field_select_card_type']['add_more']['add_more_button_blue_card_w_o_image']); }

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.