List: Remove Item (checkboxes vs radio buttons)

Created on 8 April 2025, about 1 month ago

Problem/Motivation

The ECA Action 'List: Remove Item' is not working when the list of items/options is displayed as radio buttons (that is, selection is limited to 1). However, it is working as expected when the list of items/options is displayed as checkboxes (that is, selection is unlimited).

Steps to reproduce

  1. Create a form with a list of items (in my example, I created a form with a list of colors to choose from)
  2. Go to the "Manage Fields" for the form. Edit the field corresponding to the list of items. For "Allowed number of values", select "Limited" (1).
  3. Create a ECA model:
  4. Start Event: After Build Form
  5. Action: (Unconditional) List: Remove Item
  6. Enter the token name for the list
  7. Select "Drop first" as the Method.
  8. Save the ECA model
  9. On browser, load/display the form. Observe that the first item on the list is not removed.
  10. Go back to the "Manage Fields" for the form. Edit the field corresponding to the list of items. For "Allowed number of values", select "Unlimited".
  11. Save the ECA model
  12. On browser, load/display the form. Observe that the first item on the list is removed.

I looked at ECA log. I think this is happening because when the list of items is displayed as checkboxes, in ECA log, I was able to see the tokens for each of the list options. (Please see attached screen captures "ColoursAsCheckboxes.png" and "TokensColoursAsCheckboxes.png".
However, when the options are displayed as radio buttons, in ECA log, I can only see the token for the selected option, and no tokens are found for the other options that are not selected. (Please see attached screen captures "ColoursAsRadiobuttons.png" and "TokensColoursAsRadiobuttons.png".

I'm using Drupal 11.1.5 and ECA 2.1.6. I've also attached a screen capture of my ECA model: RemoveListItemModel.png

I'm not sure if this is a bug or not - My ultimate goal is to remove a list item after the form is built, however, the list of items must be displayed as radio buttons (i.e. limited selection to 1).

Thank you for any help/suggestion!

🐛 Bug report
Status

Active

Version

2.1

Component

User interface

Created by

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

  • Issue created by @ikam
  • 🇩🇪Germany jurgenhaas Gottmadingen

    This is not really nice to review a problem to open 5 screenshots trying to make sense of it. If you want someone to review a problematic ECA model, you should create the most simple one that reproduces the problem, export that into an archive and upload that.

    But from reading through your steps to reproduce, the steps 5-7 don't make any sense. The action plugin to remove an item from a list work with a token that holds a list. You're trying to change a read-only token that gives you access to a form value. You may want to go to the ECA Guide and see the token chapter, which explains that tokens are read only, if they are provided by the system. Only tokens that you created in ECA can be modified.

  • Hi Jurgen - sorry for the confusion. I have exported the ECA model and uploaded here. The model works for a list of items that is presented as checkboxes (i.e. unlimited selection). The model does not work for a list of items presented as radio buttons (limited to 1 selection).

  • 🇩🇪Germany jurgenhaas Gottmadingen

    Ah, you're using the token form:values:field_colour_select as the list to be modified, that's not supposed to be working at all. That list gets modified by the eca_list_remove action, but it's not passed back to the form definition.

    You should instead read the list of available options with the Form field: get options action, modify that list, and then set the options back with the Form field: set options action. Having said that, I'm not sure if this can be done in the after build event, or if it shouldn't be done in the form build event. You may have to experiment with that.

  • Hi Jurgen - I got it to work per your suggestion. I have to use the Build Form event, then used Form Field: Get Options action to get the current list of colors. Using the List: Remove Item action, I was able to removed the 'N/A' option from the list of colors. I then used Form Field: Set Options to set the new list back to the form. Also, now I understand why using List: Remove Item the way I did originally is incorrectly, and I now understand the intended/correct usage of List: Remove Item. Thank you so much for your help!!

    I've attached my updated model for anyone interested.

Production build 0.71.5 2024