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

Created on 7 August 2025, 17 days 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
    17 days 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
    16 days 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
    12 days 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
    8 days 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
    8 days ago
    Total: 535s
    #574326
Production build 0.71.5 2024