ECA Form: add NOT value condition to "Form field: add state" action

Created on 7 August 2025, 2 months ago

Problem/Motivation

I cannot specify a field state condition as "not a value".
Even if I manually specify the field state condition with token, the comparison value configuration will not be respected because the action code sets the comparison value to TRUE as long as the condition is not an exact match with "value".

Steps to reproduce

Proposed resolution

1. Add a new field state condition option !value
2. Check for the condition !value OR value when setting the condition comparison value.

Remaining tasks

User interface changes

API changes

Data model changes

Feature request
Status

Active

Version

3.0

Component

Code

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

Merge Requests

Comments & Activities

  • Issue created by @starlight-sparkle
  • Pipeline finished with Failed
    2 months ago
    Total: 407s
    #566824
  • MR has some PHPStan failures but they don't appear to be caused by my changes.

  • 🇨🇭Switzerland boromino

    The code works. However, it would be more user friendly if adding a #state to only show (and require/make mandatory) the value form field if "value" or "NOT value" are selected in the condition form field (this may need corresponding form validation). Therefore, I set this issue to "Needs work".

    It's a nice feature, but is it really necessary? Can the same not be achieved by using the opposite state for the same value? E.g. visible if value = "something" equals to invisible if value = anything else. Or is there a use case that can not be handled this way?

  • However, instead of only adding to the value form field description, it would be more user friendly adding a #state to only show (and require/make mandatory) the value form field if "value" or "NOT value" are selected in the condition form field (this may need corresponding form validation).

    I can do that, but it's worth noting that the original action did not implement this either; the main use case of ECA is with BPMN, which isn't compatible with #states and only works with a small handful of Drupal form elements.

    It's a nice feature, but is it really necessary? Can the same not be achieved by using the opposite state for the same value? E.g. visible if value = "something" equals to invisible if value = anything else. Or is there a use case that can not be handled this way?

    I am not sure if it is an issue related to the theme I was using, but when I used "visible if value = something", it did not make the fields invisible when a different value was selected. It only seemed to apply the "display: none;" style if I inverted the condition ("invisible if !value = something").

  • 🇨🇭Switzerland boromino

    I can do that, but it's worth noting that the original action did not implement this either

    That's correct. I brought it up because you have changed the value form field description accordingly. Therefore I think it would make sense to also add a state condition within this issue.

    According to https://www.lakedrops.com/en/blog/drupals-modeler-api-released-learn-abo... version 3 of the BPMN modeler now supports Drupal form states:

    This property panel is now replaced by the off-canvas container from Drupal core, and the configuration forms are native Drupal Form API forms. That allows for tailored form field widgets as well as states, so that individual fields can be hidden depending on context.

  • Pipeline finished with Failed
    2 months ago
    Total: 515s
    #568236
  • First commit to issue fork.
  • 🇩🇪Germany jurgenhaas Gottmadingen

    This looks nice. I've rebased the MR so that tests should now be green. If no objections come up, this could be merged and then back ported to 2.1.x

  • Pipeline finished with Success
    about 2 months ago
    #571290
  • 🇨🇭Switzerland boromino

    If the value form field is visible, shouldn't it also be required (which would also require a server side validation)? Drupal usually stores the form field value if set, although the form field is invisible. Should the value be removed in such cases?

  • 🇩🇪Germany jurgenhaas Gottmadingen

    If the value form field is visible, shouldn't it also be required (which would also require a server side validation)?

    That may be great, I guess it should also be possible. At least worth a try. I'll set this back to NW for this.

    Drupal usually stores the form field value if set, although the form field is invisible. Should the value be removed in such cases?

    I think that's not common practice, and it's not necessary if the rest of it is implemented correctly, i.e. the value will only be used when needed, i.e. it the type is either value or not value.

    Also, it seems to be a benefit to keep the value, especially when you play around with different setting. In that case, it's rather positive if the value is kept should you later come back to that setting.

  • Pipeline finished with Success
    about 2 months ago
    Total: 573s
    #574298
  • If the value form field is visible, shouldn't it also be required (which would also require a server side validation)?

    Applied suggestion.

  • Pipeline finished with Success
    about 2 months ago
    Total: 535s
    #574326
  • 🇨🇭Switzerland boromino

    The code looks good and works including validation of the value configuration form field.

    Although the same might be possible inverting the existing conditions, it does make sense especially in cases where you would have to check for a lot of values instead of excluding 1 value.

    The label seems to be technical, maybe it would make sense to use "value NOT" instead of "NOT value". Anyway, setting this to RTBC.
    @starlight-sparkle Thanks for that feature!

  • Pipeline finished with Success
    about 1 month ago
    Total: 632s
    #593999
    • jurgenhaas committed 48a8ce43 on 2.1.x
      [#3540135] feat: ECA Form: add NOT value condition to "Form field: add...
  • 🇩🇪Germany jurgenhaas Gottmadingen

    Merged and back ported to 2.1

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

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

    Maintainers, please credit people who helped resolve this issue.

Production build 0.71.5 2024