Thank you for this wonderful module. It's working great with normal Select fields. However, I am facing issues when used with Tagify.
Problem/Motivation
When the Dependent Dropdown (child field) is a Tagify Select Widget, its not populated with options.
Steps to reproduce
1. Setup the two Dependent Fields (Field A and Field B) as instructed in the module. Make sure its working as expected with normal Select Widget.
2. In the Manage Form Display section, change the Widget of the Child field (Field B) to Tagify Select.
3. Check if the Child field (Field B) is updated/populated with options after changing the Parent Field (Field A).
4. Child field (Field B) is Empty, not populated.
Proposed resolution
To confirm if it is an issue from Tagify's side, I did a small experiment with a basic node form. I created two fields Select A and Select B whose Widgets are set to Tagify Select. I used the standard ReplaceCommand, which worked as expected. The child field is populated with the options. Since the following code is working fine with Tagify Select, we can conclude that the fix has to come from this, Dependent Fields, module.
<?php
use Drupal\Core\Ajax\AjaxResponse;
use Drupal\Core\Ajax\ReplaceCommand;
function experiments_form_node_page_form_alter(
array &$form,
\Drupal\Core\Form\FormStateInterface $form_state,
string $form_id
): void {
$form['field_select_b']['#prefix'] = "<div id='test-ajax-block'>";
$form['field_select_b']['#suffix'] = "</div>";
$form['field_select_a']['widget']['#ajax'] = [
'callback' => 'just_a_test_callback',
'event' => 'change',
'wrapper' => 'test-ajax-block',
'progress' => ['type' => 'throbber', 'message' => NULL],
];
}
function just_a_test_callback(array &$form, \Drupal\Core\Form\FormStateInterface $form_state): AjaxResponse {
$form['field_select_b']['widget']['#options'] = [
'orange' => 'Orange',
'apple' => 'Apple',
'banana' => 'Banana',
];
$renderer = \Drupal::service('renderer');
$rendered = $renderer->render($form['field_select_b']);
$response = new AjaxResponse();
$response->addCommand(new ReplaceCommand('#test-ajax-block', $rendered));
return $response;
}

So, I started digging into the module's code. The module uses a custom Ajax Command named UpdateOptionsCommand which is implemented with custom javascript at update-options-command.js. Not sure which one would be a better option.
1. Making changes to the implementation of UpdateOptionsCommand?
2. OR skipping it (UpdateOptionsCommand) when the Widget type is Tagify Select.
When the Widget type is Tagify Select, we could use ReplaceCommand maybe?
Would be grateful for any support or guidance from the maintainers.
Note: There are two other issues related to Tagify Select, but they are different. This issue addresses a different problem.
| Comment | File | Size | Author |
|---|---|---|---|
| 2026-02-25_18-51_1.png | 8.54 KB | sandeshyadav |
Issue fork dependent_fields-3575698
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #3
sandeshyadav commentedComment #4
pcambraIs this code AI generated? what does this has to do with paragraphs?
Comment #5
sandeshyadav commented@pcambra,
1. No, it is NOT AI-generated.
2. So that it does not break inside paragraphs. Without the following, it was breaking when used inside paragraphs. The first combo of select fields would work, but in the next combo, the dropdown was not populated. The issue was coming from how the wrapper divs are generated for paragraphs. With this snippet, it works for both paragraphs and normal fields. I added this because my use-case was inside paragraphs. And there are many people who use dependent fields inside paragraphs. It makes the dependent field work with Paragraphs and Tagify.
The need for handling paragraphs differently comes from how the wrapper divs are generated for paragraphs.
Comment #6
pcambraThanks @sandeshyadav!
I wonder that given that we have the UpdateOptionsCommand, shouldn't this be done in a custom command instead? I'm testing the code today.
edit: We might want to explore having Plugins per widget, each one associated to a command?
Comment #7
pcambraThis works great, definitely merging this and creating a follow up for the idea in #6
Comment #8
pcambraComment #10
sandeshyadav commentedThank you, @pcambra. The reason for not doing it in a custom command was that all the widget logic/interaction is already handled by Tagify once we add a simple
ReplaceCommand. However, for better code organization, I will add a custom command as per your comment.Regarding Plugins per widget, we should definitely do that in the long term.
Comment #11
pcambraReopening this because the edit workflow doesn't work for existing content.
Comment #12
pcambraComment #13
pcambraFalse alarm :)