Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
When trying to create a data comparison condition the negate option/operator is missing.
I tried several combinations including != as the operator, but it wasn't until I exported the config using Configuration Update Manager that I noticed the negate option in the YAML. By changing the option from false to true and re-importing my Rule triggers correctly, but there is no negate option inside the UI
Comment | File | Size | Author |
---|---|---|---|
#11 | 2827106-11.interdiff-3-11.txt | 3.86 KB | jonathan1055 |
#11 | 2827106-11.negate-option.patch | 4.3 KB | jonathan1055 |
|
Comments
Comment #2
intrafusionComment #3
coderdan CreditAttribution: coderdan at Phase2 for Workday, Inc. commentedComment #4
manicato CreditAttribution: manicato commentedWorks for me. Thanks.
Comment #5
keboca CreditAttribution: keboca as a volunteer commentedhey @intrafusion, thank for the heads-up!
It works perfectly!
Comment #6
keboca CreditAttribution: keboca as a volunteer commentedComment #7
keboca CreditAttribution: keboca as a volunteer commentedComment #8
keboca CreditAttribution: keboca as a volunteer commentedI am not sure, if someone has merged it or created a pull request for this patch. Reason why I re-defined "Needs works" status back.
Comment #9
gsquirrelAlso wanted to negate a rule - thanks for the tip on export/import
Comment #10
jonathan1055 CreditAttribution: jonathan1055 as a volunteer commented@keboca This has not been merged yet, so setting to 'Needs Review' and re-queuing the patch. This issue will also need a github pull request, which I can do if no-one above wants to.
Comment #11
jonathan1055 CreditAttribution: jonathan1055 as a volunteer commentedBased entirely on coderdan's patch in #3 the only change to that code is to use 'fieldset' instead of 'details' so that the elements of the form are consisent, i.e. the negate section renders the same as the data. operator and comparison value.
During manual testing I realised I did not know 'contains' and 'in' were allowed values, until I had read the source code. Hence I have added these valid values to form description in src/Plugin/Condition/DataComparison.php and ensured that the operator name is not case-sensitive.
I also added test coverage of negating a rule condition in ConfigureAndExecuteTest.php
Github commit https://github.com/jonathan1055/rules/commit/1f755660e9a63dd28ee5b42b49d...
Travis build https://travis-ci.org/jonathan1055/rules/builds/289699733
Pull request https://github.com/fago/rules/pull/494
Jonathan
Comment #12
fagoGreat work, thank you! Merged!
Comment #14
jonathan1055 CreditAttribution: jonathan1055 as a volunteer commentedThanks fago. I'm getting the hang of Travis, Github and Pull Requests now.
I am going to look at some other issues which had patches from a long time ago, which will need a re-roll and restesting.