Score:0

How to target buttons to add a new paragraph field

cn flag

In a form_alter hook I'm trying to target the buttons to add a new paragraph but can't seem to target the specific buttons. The buttons are multiple entity references with unlimited cardinality, but for my use case I would like for once one entity is chosen, only that entity can be chosen again in the repeater, which is why I'm trying to disable the other buttons. I want to allow unlimited cardinality but only one paragraph type to be chosen at a time. This works to unset the entire row of buttons...

$form['field_select_card_type']['widget']['add_more']

But this does not work to target the specific button...

$form['field_select_card_type']['widget']['add_more']['add_more_button_grey_card_w_image']

Any help or suggestions?

leymannx avatar
ne flag
I don't understand exactly what you are trying to do, where, and how. In a form alter hook you try to target a button. To add a new paragraph. I don't get the connection. Can you please add more detailed info?
Shawn W avatar
cn flag
Yes, in a form alter hook, I've updated my question.
I sit in a Tesla and translated this thread with Ai:

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.