When I visit http://my-site.local/admin/structure/conditional_fields/taxonomy_term/VO... I get the following error:
Warning: Undefined variable $entity_type in Drupal\conditional_fields\Form\ConditionalFieldForm->buildTable() (line 297 of modules/contrib/conditional_fields/src/Form/ConditionalFieldForm.php)
Link to code line:
https://git.drupalcode.org/project/conditional_fields/-/blob/8.x-1.x/src...
So $entity_type and also $bundle_name which is used a little further down are not declared in this method/function. This can't work. I don't understand how this module works so I am not able to fix this on my own.
if (empty($form_display_entity) && $entity_type == 'taxonomy_term') {
$form_display_entity = $this->entityTypeManager->getStorage('entity_form_display')->create([
'targetEntityType' => 'taxonomy_term',
'bundle' => $bundle_name,
'mode' => 'default',
'status' => TRUE,
]);
}
Steps:
- Got to /admin/structure/conditional_fields/taxonomy_term/YOUR_TAXONOMY
- Notice that it will not show the option to add a new dependency and it will show an message at the log messages.
| Comment | File | Size | Author |
|---|---|---|---|
| #8 | example_undefined-variable.png | 161.09 KB | lucienchalom |
| #5 | Img 06 - phpcs_ConditionalFieldForm.PNG | 8.86 KB | gabriel.abdalla |
| #5 | Img 05 - After Patch 3191870-4.patch.PNG | 18.84 KB | gabriel.abdalla |
| #5 | Img 04 - After Patch 3191870-4.patch.PNG | 30.03 KB | gabriel.abdalla |
| #5 | Img 03 - Before Patch 3191870-4.patch.PNG | 130.32 KB | gabriel.abdalla |
Comments
Comment #2
kitikonti commentedOk maybe I found the solution. But someone who knows what he is doing should confirm this :-).
Comment #3
coaston commentedHello,
I found this issue when i tried to visit different bundle, not taxonomy, but schedule (business rules module) and i had the same error, after that I found it does not matter which bundle I select in conditional fields - i am getting the same error. So I tried to apply you path and it seems it works fine and no warnings.
Looks good. thx
Comment #4
hmendes commentedRe-rolling patch from #2 for the 4.x-dev version.
Comment #5
gabriel.abdalla commentedSteps performed:
1. Installed dev version of module using composer: lando composer require 'drupal/conditional_fields:4.x-dev@dev'
2. Created a "Test Vocabulary" (machine name: test_vocabulary)
3. Added few test terms to "Test Vocabolary" (Image attached).
4. Accessed path /admin/structure/conditional_fields/taxonomy_term/test_vocabulary
5. Checked logs at Reports -> Recent log messages. Error was reproduced (images attached).
6. Applied patch 3191870-4.patch.
7. Code review performed on changed file.
8. Run phpcs for standards Drupal and DrupalPractice against changed file.
9. Deleted log messages at "Reports -> Recent log messages".
10. Tested again (steps 4 and 5). Issue was fixed with patch (images attached).
Few phpcs fixes are required in file src/Form/ConditionalFieldForm (image attached) but they are not related to changes in 3191870-4.patch.
Thus they can be addressed in other issues.
Comment #6
dianacastillo commentedUsing drupal 9.37 after this patch i get
Comment #7
landure commented@dianacastillo : the ServiceNotFoundException is solved by running `drush cr`.
Comment #8
lucienchalom commentedI was looking into the module and this same problem happens in:
Contact message, Content moderation state, File, custom menu links, url alias, shortcut links and taxonomy.
all of them I found in /admin/structure/conditional_fields
attached a print of one of the errors, as an example.
Comment #9
bruno.bicudo#4 applied smoothly, no errors on patch application.
It indeed requires a
drush crto solve the service DI pointed in #7.I tested with every item on the list to check what #8 pointed, also created some random conditionals for different targets, and still no errors on the log after the patch.
Moving to RTBC :)
Comment #10
crutch commentedexperienced this issue at /config/people/accounts/conditionals
patch works thank you
Comment #12
saurabh-2k17 commentedThank you everyone for your efforts.