Show/Hide stopped working after Drupal core 9 to 10 upgrade

Created on 10 July 2023, 12 months ago
Updated 28 March 2024, 3 months ago

I have updated my website from D9 to D10 and everything looked nice. However, I have noticed that the conditional fields do not work any more. I have a dozen of various show/hide rules and none of them are working now.

My config: D10.1.1, PHP8.1, conditional_fields 4.0.0-alpha3

🐛 Bug report
Status

Postponed: needs info

Version

4.0

Component

Code

Created by

🇭🇷Croatia devad

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

Comments & Activities

  • Issue created by @devad
  • 🇸🇪Sweden arne_hortell

    Did you solve this perhaps?
    Im in the same situation.

  • 🇸🇪Sweden arne_hortell

    For me it turned out that some jquery functions had to be enabled in modules, after enabling these, it works
    JQuery Draggable
    JQuery Droppable

  • 🇭🇷Croatia devad

    Re #3:

    Thanks for reporting.

    I have both JQuery UI Draggable and JQuery UI Droppable enabled. But my reported issue is still here.

  • 🇸🇪Sweden arne_hortell

    What if you run cron and clear cache?

    drush core:cron
    drush cr

  • 🇸🇪Sweden arne_hortell

    This is a longshot...

    For me i have content types which have droplists that show selectable entity relations to other nodes.
    After i activated the above modules, i also migrated these selectable nodes and i think it might started to work after that.

    It might, just might be that if a node form, have a entity reference selectable field and there is no items selectable in that, it might
    fail silently and as such prohibit the conditional fields to work as all fields are "Not in good shape", if you understands me?
    As said, its a longshot.

  • 🇭🇷Croatia devad

    This issue still exists in alpha5 as well.

  • 🇭🇷Croatia devad

    Here are some examples which might be useful for issue-reproduce purpose:

    Condition which works nicely in my case:
    Target controlled by "list type" field with Condition: "Value" and Values input mode: "Any of these values (OR)"

    Does not work:
    Target controlled by "list type" field with Condition: "Value" and Values input mode: "Insert value from widget"

    Does not work:
    Target controlled by "entity reference type" field with Condition: "Value" and Values input mode: "Insert value from widget"

    Does not work:
    Target controlled by "entity reference type" field with Condition: "Value" and Values input mode: "Any of these values (OR)"

    Note: All of these conditions worked nicely before I made the D10 upgrade.

  • 🇯🇵Japan hktang

    I am having the same issue. We have been using an older version of conditional fields (1.x-dev). It worked as expected in Drupal 9.5.

    After upgrading conditional fields to 4.x, it stopped working in 9.5 and 10.x.

  • 🇳🇱Netherlands firfin

    I just installed this on D10 to replace field_formatter_conditions (fico) module which does not have a D10 version.
    I never got any field to have it's visibility altered (not on display nor on edit).

    Also using Display Suite module, so that might be part of it too.

  • 🇮🇳India MukhtarM

    The states API have a change recently in core, see this: https://git.drupalcode.org/project/drupal/-/compare/308e696f76fc33d6a5d8... on issue: https://www.drupal.org/project/drupal/issues/1149078 🐛 States API doesn't work with multiple select fields Needs review . Idk conditional_fields making use of states API, but posted if that helps.

  • 🇺🇸United States tommyddp

    Seeing this behavior as well. Tried to enable jquery_ui_draggable and droppable and clear the cache but no dice. The upgrade to d10 from 9.5 broke the functionality.

  • Status changed to Postponed: needs info 4 months ago
  • 🇩🇪Germany diqidoq Berlin | Hamburg | New York | London | Paris

    Thanks for all the efforts in here but there are very different reports in here. We need to clean up the issue and need a status of what is wrong and what is right and a better issue summary. What is left? What is mistakenly considered to be a issue and what is simply wrong setup. Anyone involved willing to clarify? Thanks!

  • Status changed to Active 4 months ago
  • 🇭🇷Croatia devad

    Re: #13

    Ok. I'll try to help. Let's do a simple reproduce.

    Clean standard Drupal 10.2.4 + Conditional Fields 4.0.0-alpha5 installation.

    Visit /admin/structure/taxonomy/manage/tags/overview and create few Tag terms: tag1, tag2, tag3...

    Visit: /admin/structure/conditional_fields/node/article and add new dependency:

    - Target field: Body (body)
    - Control field: Tags (field_tags)
    - Keep the rest default and proceed with "Add Dependency" button.

    At the next screen:

    - Condition: Value
    - Values input mode: Insert value from widget
    - Inside the Tags field select: tag1
    - Keep everything else default and save settings

    Clear caches just in case...

    Go to Add new Article form (/node/add/article). The "Body" field is hidden by default and it should become visible if "tag1" Tag term is selected. But it does not work. When "tag1" term is selected inside the "Tags" field - the "Body" field is not becoming visible.

    It may help for debug... additionally, a few JS errors are visible inside my Chrome browser's console:

    Uncaught TypeError: reference.indexOf is not a function

    It may help also... the attempt to edit newly created dependancy fails with error message:

    The website encountered an unexpected error. Try again later.
    
    InvalidArgumentException: Value is not a valid entity. in Drupal\Core\Entity\Plugin\DataType\EntityReference->setValue() (line 106 of core/lib/Drupal/Core/Entity/Plugin/DataType/EntityReference.php).
    Drupal\Core\Field\FieldItemBase->writePropertyValue('entity', Array) (Line: 293)
    Drupal\Core\Field\Plugin\Field\FieldType\EntityReferenceItem->onChange('target_id', ) (Line: 239)
    Drupal\Core\Field\Plugin\Field\FieldType\EntityReferenceItem->setValue(Array, ) (Line: 208)
    Drupal\Core\TypedData\TypedDataManager->getPropertyInstance(Object, 0, Array) (Line: 91)
    Drupal\Core\Field\FieldTypePluginManager->createFieldItem(Object, 0, Array) (Line: 41)
    Drupal\Core\Field\FieldItemList->createItem(0, Array) (Line: 69)
    Drupal\Core\TypedData\Plugin\DataType\ItemList->setValue(Array, 1) (Line: 107)
    Drupal\Core\Field\FieldItemList->setValue(Array, 1) (Line: 657)
    Drupal\Core\Entity\ContentEntityBase->set('field_tags', Array) (Line: 566)
    Drupal\conditional_fields\Form\ConditionalFieldEditForm->getDummyField('node', 'article', Array, Object, Array) (Line: 171)
    Drupal\conditional_fields\Form\ConditionalFieldEditForm->buildForm(Array, Object, 'node', 'article', 'body', 'a6457cfb-fa78-460e-abe4-b725dd0aacf8')
    call_user_func_array(Array, Array) (Line: 536)
    Drupal\Core\Form\FormBuilder->retrieveForm('conditional_field_edit_form', Object) (Line: 283)
    Drupal\Core\Form\FormBuilder->buildForm(Object, Object) (Line: 73)
    Drupal\Core\Controller\FormController->getContentResult(Object, Object)
    call_user_func_array(Array, Array) (Line: 123)
    Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 627)
    Drupal\Core\Render\Renderer->executeInRenderContext(Object, Object) (Line: 124)
    Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext(Array, Array) (Line: 97)
    Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 181)
    Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object, 1) (Line: 76)
    Symfony\Component\HttpKernel\HttpKernel->handle(Object, 1, 1) (Line: 58)
    Drupal\Core\StackMiddleware\Session->handle(Object, 1, 1) (Line: 48)
    Drupal\Core\StackMiddleware\KernelPreHandle->handle(Object, 1, 1) (Line: 28)
    Drupal\Core\StackMiddleware\ContentLength->handle(Object, 1, 1) (Line: 32)
    Drupal\big_pipe\StackMiddleware\ContentLength->handle(Object, 1, 1) (Line: 106)
    Drupal\page_cache\StackMiddleware\PageCache->pass(Object, 1, 1) (Line: 85)
    Drupal\page_cache\StackMiddleware\PageCache->handle(Object, 1, 1) (Line: 48)
    Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object, 1, 1) (Line: 51)
    Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object, 1, 1) (Line: 36)
    Drupal\Core\StackMiddleware\AjaxPageState->handle(Object, 1, 1) (Line: 51)
    Drupal\Core\StackMiddleware\StackedHttpKernel->handle(Object, 1, 1) (Line: 704)
    Drupal\Core\DrupalKernel->handle(Object) (Line: 19)
  • Status changed to Postponed: needs info 4 months ago
  • 🇩🇪Germany diqidoq Berlin | Hamburg | New York | London | Paris

    Thanks for the report but...

    #14 Clean standard Drupal 10.2.4 + Conditional Fields 4.0.0-alpha5 installation.

    ... what does that has to do with this issue which is about issues of already existing dependencies in an Drupal core update between 9.5 to 10?

    Also, in issues please always test also against latest 4.x dev to get it fixed for upcoming releases. Apart from that: I cannot reproduce what you tested. simplytest.me is not always a good way to test issues because it has limitations and own issues. It is good to tryout modules but not the best to test against bugs.

  • 🇭🇷Croatia devad

    What does that has to do with this issue which is about issues of already existing dependencies in an Drupal core update between 9.5 to 10?

    As much as I have tested this issue is for general 4.x branch compatibility with D10. Not for D9 to D10 upgraders only.

    I cannot reproduce what you tested.

    I tested it again with 4.x-dev and the issue remains the same. Did you try to create the described dependency and edit it afterwards? No error message for you?

  • 🇩🇪Germany diqidoq Berlin | Hamburg | New York | London | Paris

    this issue is for general 4.x branch compatibility with D10

    The 4.x branch is compatible with D10 and we run many test sites with it.

    No it is the upgrade issue here, where users want their settings back from D9 and expect them to work like before. Which in fact still has some base flaws and missing direction in here and very mixed reports, yes, but is not a general D10 compatibility issue. Which is far too generic anyway, because then you can count all issues into it. An alpha release has flaws yes, but is cannot be handled in a Drupal 10 compatibility issue. This is not how we can fix issues and track them.

  • 🇩🇪Germany diqidoq Berlin | Hamburg | New York | London | Paris

    Reports like this ...

    In our case, it seems most issues are related to the default value (require/optional) of the field itself, so they are not really caused by this module.

    For me i have content types which have droplists that show selectable entity relations to other nodes.
    After i activated the above modules, i also migrated these selectable nodes and i think it might started to work after that.

    and man others ...

    .. indicate that this issue has turned into a weird mixed issue from users who report that something is not working for them in the it used tow work in D9. This is not how we can handle issues and fix them. I have a very hard time to track all this in here and would kindly ask you to please think twice before posting. We need an issue for each case and each case needs a helpful traceable and reproducible report. Thanks for understanding.

  • 🇭🇷Croatia devad

    Re: #17

    You are right @dqd. It is the upgrade issue here.

    The error messages which appeared in my tests described in my comments #14 and #16 are due to known issue described here: #1959170: Applying dependency on entity reference/autocomplete field does not work . Sorry for noise.

  • 🇨🇦Canada Liam Morland Ontario, CA 🇨🇦

    I found that for conditionals controlled by entity reference fields, "Insert value from widget" does not work. It worked when I replaced that with "Any of these values" and entered the one desired value.

  • It only works with version 4.0.0-alpha1. Both 4.0.0-alpha3 and 4.0.0-alpha5 are breaking the validation of the conditional fields.

Production build 0.69.0 2024