Problem/Motivation

There isn't an action plugin that can set/change a field description. The one that is provided here is based on Form field: Set label.

Issue fork eca-3583899

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

bisonbleu created an issue. See original summary.

bisonbleu’s picture

Status: Active » Needs review

The MR fails on a PHPCS error reported for FormFieldSetDescription.php:36

----------------------------------------------------------------------------------------------------
FOUND 0 ERRORS AND 1 WARNING AFFECTING 1 LINE
----------------------------------------------------------------------------------------------------
 36 | WARNING | Unused variable $element.

This error also occurs with the existing FormFieldSetLabel.php:35. I'm not sure what to do about this…?

jurgenhaas’s picture

Status: Needs review » Needs work

I don't see any PHPCS errors in the pipeline of the MR. But there are a number of PHPStan errors that mostly seem to be related to the wrong namespace of the action plugin.

bisonbleu’s picture

Assigned: bisonbleu » Unassigned
Status: Needs work » Needs review

Oops! Sorry about that, I had tested it in a custom module. Fixed!

jurgenhaas’s picture

Status: Needs review » Needs work
Issue tags: +Needs tests

I left a couple of comments in the MR, but it looks great already.

bisonbleu’s picture

Status: Needs work » Needs review

I provided fixes for your comments.

As for «Needs tests», do you mean to update /eca/modules/form/tests/src/Kernel/FormActionsTest.php?
Not sure how to move forward with that…

jurgenhaas’s picture

The MR looks great, thanks for that.

Yes, the tests should go into FormActionsTest. If you want to give that a try, maybe with assistance from AI, then please give it a try. Otherwise, I'll get to it at some point. No worries.

jurgenhaas’s picture

Congrats, this is great. One last thing: should we add a second test in the same method to make sure that the #description is unset if we provide an empty description?

jurgenhaas’s picture

Status: Needs review » Fixed
Issue tags: -Needs tests

Looking great, thanks a lot @bisonbleu

Maybe the test could be optimized by calling the action multiple times on the same form build event, but that's not worth holding back the issue for that.

So, I've merged this.

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.