Help with targeting a Form element

Created on 6 May 2025, 9 days ago

Problem/Motivation

I am trying to use ECA Helper to adjust the help text on a Group form.

I know that I am targeting the correct for becase at the end of the ECA I pop up a Message to say so.

However I don't think I have properly understood have to target a form element for change.

Event: Prepare content entity form
Action: ECA Helper: Form field set value

Detail as illustrated below...

I am not seeing any alteration to the value of the #edit-entity-id-0-target-id--description

The markup of of the form is...

<form class="group-relationship-class-group-node-article-add-form group-relationship-form gin--has-sticky-form-actions" data-drupal-selector="group-relationship-class-group-node-article-add-form" action="/group/1/content/add/group_node%3Aarticle" method="post" id="group-relationship-class-group-node-article-add-form" accept-charset="UTF-8" data-once="ginEditForm">
...

<div id="edit-entity-id-0-target-id--description" class="form-item__description">
  The title of the node to add to the group
</div>
...

</form>

It is simply the content of the #edit-entity-id-0-target-id--description" class="form-item__description that I am trying to alter by adding "XXX" on the end.

I have also tried to adjust the Save button value by using following the guidance...

Use "submit" for the labeled "Save" button, and "preview" for the labeled "Preview" button...

But nothing I try seems to work.

I'm sure I have misunderstood but can anyone nudge me in the right direction please.

Thanks

💬 Support request
Status

Active

Version

2.0

Component

Miscellaneous

Created by

🇬🇧United Kingdom SirClickALot Somerset

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

Comments & Activities

  • Issue created by @SirClickALot
  • 🇻🇳Vietnam zipme_hkt

    This module will use form element when define form with the Drupal Form API, it don't working with the rendered html id.

    With your case with the group module you can check on the file GroupRelationshipForm.php you can find the form element

    Here is the config

  • 🇬🇧United Kingdom SirClickALot Somerset

    Brilliant, thank you @zipme_hkt,

    I thought as much as I was easily able to target it with a simple form_alter() hook but was keen to do it using ECA for site-builder maintenance.

    Might be worth giving out some simple, easy guidance for site-builders as how they could most easily identify and target form elements. Indeed, even better than guidance, might be to somehow add something to the ECA UI for this action to help them - maybe the 'current form'

  • 🇻🇳Vietnam zipme_hkt

    @sirclickalot

    You are right, with site builder they may got trouble when find the correct element of the form, special is that form is alter by other module.

    I think I will add other Form action allow list and debug all the element of form then user can easy find and input correct element id.

  • 🇬🇧United Kingdom SirClickALot Somerset

    That would be absolutely spot on!

  • 🇻🇳Vietnam zipme_hkt

    @sirclickalot

    I added new Action "ECA Helper: Form dumper" on dev release.

    Please try it.

  • 🇬🇧United Kingdom SirClickALot Somerset

    I have installed the DEV version and set up a Form Dumper using !!form ...

    But I do not 'see' any form dump anywhere - nothing in the Watchdog log?

    Plus, my ECA never gets to show the DEBUG message but I cannot see any other notices or errors in the Watchdog either.

    Where should I expect to see it?

    Thanks

  • 🇻🇳Vietnam zipme_hkt

    Reload the page has form you will see the dump data

  • 🇬🇧United Kingdom SirClickALot Somerset

    Nope, definitely no sign of any dump anywhere at all?

    Like I said, I am not even seeing my DEBUG message suggesting that the whole ECA is not kicking in for some reason.

    What else should I try?

  • 🇻🇳Vietnam zipme_hkt

    Look like your env doesn't has symfony/var-dumper

    Please try install with `composer require symfony/var-dumper`

    • zipme_hkt committed 9f1fddc8 on 2.0.x
      #3522889 Add Form Dumper Action, add warning missing symfony/var-dumper
      
Production build 0.71.5 2024