Hi, unless I am wrong, this module should correspond to my needs, but it does not work as expected and I don't know where to start to make it work.

I have three entities: A, B and C where B and C refer to A, and C to A (one) and B (several).

In the C content type, I thus used two entity references:
- one static to nodes of types A
- one using a view where field_A is an argument and that returns a list of entity references of type B. The selected mode is "Views: Filter by an entity reference view with dynamic arguments" (thus using the DDF module), and as argument {field_A} which refers to my node of type A.

Please tell me if I do something wrong, or if not, what should I do to give you more debugging information.

Comments

maximpodorov’s picture

What does not work?

bpiwowar’s picture

Title: DDF not working » DDF not working for a dependent field with an unlimited number of values
Category: bug » feature

OK, I understood what was wrong: DDF works when the dependent field is a SELECT button, but not when it is a list of checkboxes (the user can selected an unlimited number of dependent values).

I will try to make it work, but would appreciate any help on how to add this functionality.

maximpodorov’s picture

What are field type and widget type for this dependent field?

bpiwowar’s picture

The widget type is "checkbox / radio button"
The field type is "entity reference"

fruitsalad’s picture

Hi bpiwowar and contributors,

I really would like to use the ddf module as I think it is the right tool to solve my problem.

I got two fields in a content type. One field "companies", that is an organic group. The other field "departments" that is a group itself but also group content of "companies".

I would like to achieve that when a company is selected the "departments" field shows only the departments of the selected company.

Could someone give me a glue how to achieve this with ddf, or if that is not the right tool maybe another way to solve this?

Thank you very much for your time and help!

greenrmor’s picture

Title: DDF not working for a dependent field with an unlimited number of values » RE: DDF not working for a dependent field with an unlimited number of values

@fruitsalad I think this module is not the right one for you... I recommend to use Conditional Fields module instead.. ;)

bruceci’s picture

@fruitsalad this is right module you find,
but with checkbox/radio buttom ,autocomplete wedget do not work, select wedget works good.

thinhnp.it’s picture

Hi everyone,

Could you tell me how to add dependent fields ?
I tried with select widget but It didn't work.

P/S: My situation is same as @fruitsalad.

Thanks.

yury n’s picture

Issue summary: View changes
StatusFileSize
new1.97 KB

I've created a patch that adds support for multiple value selects.

bpiwowar’s picture

Thanks Yury, the patch works great. I am trying to adapt it to handling checkboxes instead of a select form (I have ~15 items for each view, and it looks much better like this). I am a bit stuck in ddf_entityreference.module. Line 61, I replaced $result = form_select_options($element); by

    if ($instance['widget']['type'] == "options_select") {
      $result = form_select_options($element);
    } else {
      // Use $field["field_name"] and $field["langcode"] to get the name?
      $element = form_process_checkboxes($element);
      $result = drupal_render($element);
    }

but the problem is that now I don't get in the form the names of the input fields. If you have any advice on how to do this, it would allow me to finish by modifying the javascript code to handle checkboxes.

cadila’s picture

I've installed this patch and it's fixed multi-value fields. Now values are saving correctly.

cadila’s picture

Status: Active » Reviewed & tested by the community
nhck’s picture

Status: Reviewed & tested by the community » Needs work

Unfortnuately this doesn't work if your field is named:

fieldname[und]

Because then the checkboxnames

fieldname[und][1]

but javascript is confused by that.

cadila’s picture

StatusFileSize
new2.44 KB

Try this patch, it may help (first patch is already included in this patch too)

nhck’s picture

Thanks Cadilla, I haven't been able to debug this and find the reason, but as a quick feedback: The patch doesn't do the job, sorry.

cadila’s picture

nhck, try adding your own patch and help yourself and other people with this problem!

nhck’s picture

Sorry, I submitted the last answer too early
This:
>The patch doesn't do the job, sorry.
was to read
>The patch doesn't work with checkboxes, but only with select lists.

Again sorry, and in this sense it works. I made the inclusion of checkboxes/radiobuttons a feature request:
#2192557: Support Checkboxes/Radiobuttons for the dependent field

j3ll3nl’s picture

Maybe try the project: Reference field option limit

manuelBS’s picture

We now created a new module that allows to configure the list of allowed values with a view. This makes it more flexible and integrated with Drupal. You can find it at https://www.drupal.org/project/dfv if this is interesting for you.

maximpodorov’s picture

I think it's better to develop DDF project with the required functionality.

manuelBS’s picture

I absolutely agree. It just depends on the use case and the flexibility you need with the module.

maximpodorov’s picture

Status: Needs work » Fixed

The problem is fixed in the last commit.
http://cgit.drupalcode.org/ddf/commit/?id=a2d06cb
The only problem is checkboxes and radio buttons for dependent fields, since they are multiple widgets, not a single (like selector).

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.

nwom’s picture

It appears the patch was not fully committed. I have created a patch for this in the following issue: #3135414: Support Entity Reference Dependents with Multiple Values