Support for multiple "Field Collection" fields to have a dependency on all instances of the fields within that collection. For example, say you create a "Field Collection" field and checked it to have the "Number of values" set to unlimited. Then you configure the "Field Collection" field to have a checkbox and textarea field attached. When you would check the "checkbox" field you would like to then display the textarea field which you setup using the "Conditional Fields" module interface. This all works for the first instance of the "Field Collection" field. When you start creating multiple instances using the "add another item" button, the checkbox condition will not work for those additional instances. Does any one have any suggestions on how I can go about implementing this?

Thanks,
Droath

Files: 
CommentFileSizeAuthor
#195 conditional_fields-fixed_multiple_field_collection_fields-1464950-195.patch8.29 KBpaulmartin84
PASSED: [[SimpleTest]]: [MySQL] 160 pass(es).
[ View ]
#192 conditional_fields-fixed_multiple_field_collection_fields-1464950-192.patch7.21 KBamitgoyal
FAILED: [[SimpleTest]]: [MySQL] 160 pass(es), 0 fail(s), and 297 exception(s).
[ View ]
#190 conditional_fields-fixed_multiple_field_collection_fields-1464950-190.patch7.42 KBamitgoyal
FAILED: [[SimpleTest]]: [MySQL] Unable to apply patch conditional_fields-fixed_multiple_field_collection_fields-1464950-190.patch. Unable to apply patch. See the log in the details link for more information.
[ View ]
#155 conditional_fields-fixed_multiple_field_collection_fields-1464950-155.patch8.99 KBRajabNatshah
FAILED: [[SimpleTest]]: [MySQL] 160 pass(es), 0 fail(s), and 297 exception(s).
[ View ]
#153 conditional_fields-fixed_multiple_field_collection_fields-1464950-153.patch26.65 KBRajabNatshah
PASSED: [[SimpleTest]]: [MySQL] 160 pass(es).
[ View ]
#114 conditional_fields-fixed_multiple_field_collection_fields-1464950-114-no-whitespaces-do-not-test.patch8.82 KBnevergone
#109 conditional_fields-fixed_multiple_field_collection_fields-1464950-109.patch22.33 KByannickoo
PASSED: [[SimpleTest]]: [MySQL] 160 pass(es).
[ View ]

Comments

airb’s picture

same happens here.

airb’s picture

airb’s picture

Issue summary:View changes

Updated explanation of feature

FranckV’s picture

Hi, I also have the need for this functionality.

droath’s picture

Status:Needs review» Active

I have a patch that adds this functionality, I will be releasing it here soon...

droath’s picture

Status:Active» Needs review
StatusFileSize
new21.93 KB

Here is the patch that implements this functionality described above.

droath’s picture

I rerolled the patch so It could be applied from the "conditional_fields" module directory.

animelion’s picture

Status:Active» Needs review

Can't wait to test this!

Side question, would your patch possibly solve this issue as well? #262453: Grouping dependencies by dependent with OR/XOR evaluation

rhiss’s picture

i try to apply the patch online through: http://owl.cs.manchester.ac.uk/patch/patch-form.php
but the problem for the "Field Collection" fields remained.
i have the condition set by using an select box, it only works for the first item in the collection ....
any suggestion for me ?

droath’s picture

@rhiss

Can you confirm the patch was applied correctly using the third-party patching tool? If your familiar with git, you can read how to apply patches here: https://drupal.org/node/707484. It's about 3/4 way down the page, where they tell you how to apply a patch.

How many "field collection" fields are attached to the entity your working with? I have only tested with one "field collection" field attached to a node entity, but the "field collection" also has another "field collection" field attached to it as-well. On that second collection is where I have the conditional field module configured to manipulate the form. Let me know if you have a different situation, and I will adjust my patch if needed.

@animelion

I will look and see if this patch can help resolve issue.#262453: Grouping dependencies by dependent with OR/XOR evaluation

rhiss’s picture

droath thx for your attention. after checking the online-patched version i noticed, nothing was patched.
i tryed patching with git, both of you versions, from root and module dir but i get errors like "warning: squelched 26 whitespace errors
warning: 31 lines add whitespace errors." i m not so familiar with patching but i could try to do it manualy, or you could post your patched module file here, would be great!
basicly what i want to do is to have one "field collection" on a node with diffrent fields(image, file, long text,... ) and select on each added entity instance which fields i want to edit. it should become some flexible content node without content syling in the RTEditor.
i know there are other ways to do it with entity types, but with the Conditional Fields Module and FieldCollections it should work as well!

3rdLOF’s picture

Patch in #6 fails completely

conditional_fields_fixed_multiple_field_collection_fields_1464950-5-1.patch:19: trailing whitespace.
conditional_fields_fixed_multiple_field_collection_fields_1464950-5-1.patch:29: trailing whitespace.
conditional_fields_fixed_multiple_field_collection_fields_1464950-5-1.patch:32: trailing whitespace.
    $field_parents_string = _conditional_fields_flatten_array(array_filter($field['#field_parents'], 'is_numeric')); 
conditional_fields_fixed_multiple_field_collection_fields_1464950-5-1.patch:61: trailing whitespace.
      $array_string .= $separator;
conditional_fields_fixed_multiple_field_collection_fields_1464950-5-1.patch:126: trailing whitespace.
  foreach ($form['#conditional_fields'] as $parent_dependent_key => $parent_dependent_info) {
error: patch failed: conditional_fields.module:264
error: conditional_fields.module: patch does not apply
3rdLOF’s picture

I tried patching manually, but there are just way to many differences in the code. It looks like the latest version of CF changed quite a bit, thus making the pacth obsolete. Bummer.

Thanks for doing it thought.

droath’s picture

This patch has been altered to work with conditional_fields 7.x-3.x-dev (2012-Apr-13).

The issue that I uncovered was that we were not storing multiple conditional fields in $form['#conditional_fields'], just data for the first conditional field, which is delta 0.

For instance, say we had field $element[foo][und][0] this would index the $form['#conditional_fields'] array by the dependees/dependents field name, so it would be like this: $form['#conditional_fields']['foo'][...][...].

So when $element[foo][und][1] tried to join $form['#conditional_fields'] array it wouldn't be able too, since we were already storing that data for the dependees/dependents foo field.

The way I implemented it in the patch was by indexing the $form['#conditional_fields'] array by the field parents flatten array. So that it could accommodate for multiple conditional fields, since it now has a unique field key. So now $form['#conditional_fields'] stores data like this:

  $form['#conditional_fields'][foo:und:0][foo][...][...]...
  $form['#conditional_fields'][foo:und:1][foo][...][...]...
  $form['#conditional_fields'][foo:und:2][foo][...][...]...

Since we are now storing the field parents as a flatten key, we could then remove $form['#conditional_fields'][foo:und:0][foo][parents] array, as that's the same data collected twice. But I'll leave that up to the module maintainer.

Let me know if you have any issues with this patch, or If anyone has a better solution on how we can accommodate for this functionality.

droath’s picture

Category:support» feature
3rdLOF’s picture

Was this commited to the 17th dev release? Just wondering

Thank you very much for the reply and the patch.

3rdLOF’s picture

I tried applying it on the 17th dev release, it failed. I know you say it was made for the 13th one, but I tried it.

Hunk #7 FAILED at 465.
1 out of 8 hunks FAILED -- saving rejects to file conditional_fields.module.rej
rhiss’s picture

same here. i tried patching the last conditional_fields 7.x-3.x-dev (2012-Apr-17). didnt work.
am i missing something, is there a version 7.x-3.x-dev (2012-Apr-13)?

bigjim’s picture

Status:Needs review» Reviewed & tested by the community
StatusFileSize
new15.26 KB

I was able to apply the original patch against the 4/13/2012 -dev version (git commit b10aa5aa310). I found a "}' was missing on line 627.

The attached patch is re-rolled against the 7.x-3.x HEAD (git commit d905202fad), which is likely one commit ahead of the 4/28 -dev version on the project page right this moment.

The attached patched worked great for me. I tested in on a 3 field field collection. My first field was select box, the 2nd and 3rd fields in the collection were check boxes. I set-up my dependencies respectively between the 1st, 2nd and 3rd fields and all worked great.

bigjim’s picture

Status:Reviewed & tested by the community» Fixed

Looks like it's already in the repo as of 4/24, marking this fixed. It should be in the May 1st -dev tar ball.

bigjim’s picture

Status:Fixed» Needs review

sorry I jumped the gun doesn't look like it's actually fixed yet

3rdLOF’s picture

LAtest patch seems to have been added to latest release. (patching reports no changes)

rfc2460’s picture

Hi,

It seems that your patch references a file named "states_enhancements.js" that I do not find. Did you modify the states.js file to fix this bug ?

(and of course thanks for the work !)

Merkator’s picture

@rfc2460 > states_enhancements.js is in conditional_fields.js.

Conditional Fields: May 2, 2012 3:41
Commit 8718f66 on 7.x-3.x
by peterpoe

Consolidated states_enhancements.js and conditional_fields.effect.js in a single conditional_fields.js and rewritten states override.

http://drupal.org/node/206178/commits

wrd’s picture

I'm not having any luck applying the patch from #18 to the current dev version, and as far as I can tell, it's not implemented. Anyone else have it working?

wwhurley’s picture

I'm unable to either. Anyone else have luck?

guidotti’s picture

I was able to apply manually #13 to the current dev version (2012-May-05).
It works for multiple field collection, but stop working for fields outside a field collection.
I suppose the problem is Null returned by function conditional_fields_flatten_array in case of fields width no #field_parents.

My quick&dirty solution is to change:

function conditional_fields_flatten_array($array, $delta = 0, $separator = ':') {
-  $array_string = NULL;
+  $array_string = 'root'.$separator;

controls like this
     if (isset($field_parents_key)) {
are now useless, but not a problem.

it seems to work.

xcafebabe’s picture

@guidotti, Would be lovely if you can share your patched code. I want to test if is working as well . Thanks in advance :)

guidotti’s picture

This is the patch for 7.x-3.x 2012-May-05
There is a problem validating required fields that are not visible according to dependency rules.

xcafebabe’s picture

Thank you @guidotti and @droath

Patch from #28 works on dev branch 7.x-3.x 2012-May-05 (commit 0a9f967ffbea277fcd6ecf1ea4ba20da9503fd6c)

John Pitcairn’s picture

Patch at #28 applies and works as expected, but adds whitespace errors for me:

$ git apply -v conditional_fields_fixed_multiple_field_collection_fields_1464950-28.patch
conditional_fields_fixed_multiple_field_collection_fields_1464950-28.patch:18: trailing whitespace.
 
conditional_fields_fixed_multiple_field_collection_fields_1464950-28.patch:93: trailing whitespace.
 
conditional_fields_fixed_multiple_field_collection_fields_1464950-28.patch:120: trailing whitespace.
 
conditional_fields_fixed_multiple_field_collection_fields_1464950-28.patch:123: trailing whitespace.
 
conditional_fields_fixed_multiple_field_collection_fields_1464950-28.patch:127: trailing whitespace.
 
Checking patch conditional_fields.module...
Applied patch conditional_fields.module cleanly.
warning: squelched 22 whitespace errors
warning: 27 lines add whitespace errors.
xcafebabe’s picture

I applied the patch with this command and didn't get errors or warnings.

$ patch --verbose -p1 < conditional_fields_fixed_multiple_field_collection_fields_1464950-28.patch
Hmm...  Looks like a unified diff to me...
The text leading up to this was:
--------------------------
|diff --git a/conditional_fields.module b/conditional_fields.module
|index 497d1e6..8c05766 100644
|--- a/conditional_fields.module
|+++ b/conditional_fields.module
--------------------------
Patching file conditional_fields.module using Plan A...
Hunk #1 succeeded at 231.
Hunk #2 succeeded at 273.
Hunk #3 succeeded at 290.
Hunk #4 succeeded at 369.
Hunk #5 succeeded at 400.
Hunk #6 succeeded at 415.
Hunk #7 succeeded at 444.
Hunk #8 succeeded at 1012.
Hunk #9 succeeded at 2004.
done
irowboat’s picture

#31 working where git apply isn't. thanks!

wrd’s picture

With the latest dev version, I'm now getting:

$ patch --verbose -p1 < conditional_fields_fixed_multiple_field_collection_fields_1464950-28.patch
Hmm...  Looks like a unified diff to me...
The text leading up to this was:
--------------------------
|diff --git a/conditional_fields.module b/conditional_fields.module
|index 497d1e6..8c05766 100644
|--- a/conditional_fields.module
|+++ b/conditional_fields.module
--------------------------
Patching file conditional_fields.module using Plan A...
Hunk #1 succeeded at 231.
Hunk #2 succeeded at 273.
Hunk #3 succeeded at 290.
Hunk #4 succeeded at 369.
Hunk #5 succeeded at 400.
Hunk #6 succeeded at 415.
Hunk #7 FAILED at 444.
Hunk #8 succeeded at 1012 (offset 2 lines).
Hunk #9 succeeded at 2000 (offset -2 lines).
1 out of 9 hunks FAILED -- saving rejects to file conditional_fields.module.rej
done

Anybody have this working on a newer version?

mathes’s picture

why always new patches? i would like to see a working patch in the next dev update.

flyingkiki’s picture

can we has this features in latest dev version or can somebody provide a new patch?

dharmendra singh’s picture

i also have this issue...multiple group and conditional field not working properly....

naeluh’s picture

@wrd

were you able to get this patch to work ? http://drupal.org/node/1464950#comment-6122020

I actually got the same error as you ?

thanks

Nick

dharmendra singh’s picture

Thanks naeluh, but actually i have drupal 6.2x proublem, sorry to post in wrong place....

doliveros’s picture

I'm having problems with the patch and the latest dev version, too. Tried to manually patch it up, but there are too many code differences.

joel_osc’s picture

I am having the Hunk 7 failed at 444 as well when applying the patch to the latest (July 30) dev version. Any chance of getting a new dev build with the patch included? Or help on fixing the patch would also be appreciated!

joel_osc’s picture

Here is a patch file off latest dev using git, cheers.

joel_osc’s picture

May be a misplaced bracket in last patch...welcome to try this one.

naeluh’s picture

@joel_osc

I will try the patch and report back

thanks for your help !

semiaddict’s picture

The patch in #42 works great for me.
Thank you.

doliveros’s picture

Great, #42 works great.

drupov’s picture

Yep, the patch from #42 is working! Thanks!

jason.fisher’s picture

#42 along with the #1 patch http://drupal.org/files/conditional_fields-support_for_markup_field-1786... at http://drupal.org/node/1786232 has allowed conditional fields to work with Commerce Registration and Field Collections here.

alduya’s picture

Status:Needs review» Needs work

I tested the patch in #42 and it solves the problem for the conditional fields inside a field collection. But after that the conditional fields for the regular fields on all node types stopped working.
I traced this back to somewhere around line 260 in conditional_fields.module. The patch adds a variable $field_parents_key to point to the fields inside the field collection, but if this is only root: it should not be added.

The workaround I came up with is adding a check for the value of this variable. But this doesn't seem like a really clean solution.

      // Only add the field parents key if it is not only root:.
      if ($field_parents_key == 'root:') {
        if (!isset($form['#conditional_fields'][$field['#field_name']]['dependees'][$id])) {
          conditional_fields_attach_dependency($form, array('#field_name' => $dependency['dependee']), $field, $dependency['options'], $id);
        }
      }
      else {
        if (!isset($form['#conditional_fields'][$field_parents_key][$field['#field_name']]['dependees'][$id])) {
          conditional_fields_attach_dependency($form, array('#field_name' => $dependency['dependee']), $field, $dependency['options'], $field_parents_key, $id);
        }
      }
joel_osc’s picture

I am seeing a problem with conditional fields outside of field collections as well. I am not sure if it is the same as @alduya - the symptom is that none of the info I type into my dependent fields gets saved. I think @alduya might be on to something with the above code, however when I added it the fields on the form were no longer displayed as conditional - they were all displayed. I think this is a result of the first call to conditional_fields_attach_dependency:

conditional_fields_attach_dependency($form, array('#field_name' => $dependency['dependee']), $field, $dependency['options'], $id);

...where the $field_parents_key argument is ommited and $id is passed in as the field parent.

alduya’s picture

The problem I have is indeed that the value of the dependent field does not get saved.
I also added the check of my previous post to the code for that attaches the dependent; which fixes the conditional behaviour. But then there came errors from theconditional_fields_evaluate_dependencies which I could not get around.
Are there people who know this module better who can help out here? The patch in #42 solves the issue for conditional fields in field collections, but breaks conditional fields outside field collections.

alduya’s picture

Sorry, correction and clarification.
I first only added the check to the code that attaches the dependent (line 278). But that broke the conditional behaviour.
Then I also added the check to the code that attaches the dependee (line 290). This fixes the conditional behaviour, but the validation gives errors.

tytho’s picture

Category:feature» bug

I have applied the patch in #42, and it works for the most part, but it doesn't affect field collections inside a field collection. The Or condition also doesn't seem to be working.

michamilz’s picture

#42 works with a multiple field collection for me

monsoon’s picture

It is possible to get a copy of the module after patch #42 has been applied. Would any one please share the zip file?
I am not skilled to use git.
Thanks

aviddv1’s picture

Has anyone had any luck applying this patch to the latest version? It doesn't even patch for me.

Opensoft’s picture

Priority:Normal» Critical

Has anyone found any solution? We would like to chip in if anyone could solve the issue and provide a patch.

monsoon’s picture

I found a work around: using field collection and conditional fields modules I am able to hide collection of fields based on dependee field's value.

kaizerking’s picture

a field collection is normally attached to a host entity,hence a generic entity support is required
in my case my field collections are attached to profile2.
hence i would need conditions on two entities
1. field collection fields as fields on profile2 and mange dependencies as field collection fields as fields
2. manage dependencies of fields of a field collection item
3.manage dependencies of fields across field collection items i.e irrespective of entity they are attached to, in my case all
So, at the profile2 level the filed list includes
1. all the field collection items as field names (they are fields with respect to profile2)
2. all the fields of all the field collection items
3. any fields directly attached to profile2

aendrew’s picture

Patch from #42 applied (albeit with whitespace errors) against the dev commit from July 29, 2012 with hash de8d798ffc3d976f1ad4302b7b0af086e825a26d.

To anyone needing this functionality who is not that familiar with git (note that this will break your site for a minute or so):

0. Put your site into maintenance mode if you're concerned about users getting WSODs (Not that you really should use patched modules on a production site, but that's a discussion for another day).

1. Backup your existing conditional fields directory by moving it into sites/all (I.e., one directory below "modules" -- feel free to create a directory like sites/all/disabled to put it in if you prefer).

$ mv conditional_fields ..

2. Run the following:

$ git clone --recursive --branch 7.x-3.x http://git.drupal.org/project/conditional_fields.git

$ cd conditional_fields

3. Once in the newly-cloned conditional fields directory, checkout the older dev version:

$ git checkout de8d798ffc3d976f1ad4302b7b0af086e825a26d

How did I get that version hash? git log shows all commits in the branch.

4. Download and apply the patch from #42:

$ wget http://drupal.org/files/conditional_fields_fixed_multiple_field_collection_fields_1464950-42.patch

5. Apply using git:

$ git apply -v conditional_fields_fixed_multiple_field_collection_fields_1464950-42.patch

I haven't really had to checkout an older dev version to get a patch to apply before, figured I'd document the process in case it helps someone!

dagomar’s picture

Thank you Aendrew, your steps work for me.

arosboro’s picture

@jason.fisher (#47), I've been working on Commerce Registration for a client, and that's why I wrote the markup field patch. I'm going to look at the patch in #42 and see about updating it to apply to the latest commit in the repo, so you won't need to follow aendrew's instructions (#59).

arosboro’s picture

Here's the updated patch, tested it for an event with two registrations in Drupal commerce.

arosboro’s picture

Status:Needs work» Needs review
klonos’s picture

Title:support for multiple "Field Collection" fields» Support for multiple "Field Collection" fields.

Thanx for sharing Andrew ;)

aendrew’s picture

@arosboro -- Thanks for doing that! I can confirm that it patches cleanly against 7.x-3.x, revision hash ec8fdd9adcf942337e07b66157d159c418923bbb.

kaizerking’s picture

@ arosboroIts great work and thanks,
still this needs this mentioned at# #58 the

2. all the fields of all the field collection items

dependent and dependees listing of all the fields of all the field collection items attached to host entity eg:hostEntity - profile2 profile

kenorb’s picture

Status:Needs review» Reviewed & tested by the community
StatusFileSize
new22.5 KB

Fixing the patch file by removing 'a/' and 'b/' to prevent the error (can't find file to patch at input line 5) when using drush with .make file.
Otherwise it works as it should.

artis’s picture

I can confirm that this patch applies to 7.x-3.x-dev (2012-Nov-12) and works correctly.

dagomar’s picture

#67 works for me on 2 different installs.

kenorb’s picture

Status:Reviewed & tested by the community» Patch (to be ported)
aendrew’s picture

I don't know about you folks, but I'm so excited by this most recent status update that I can barely sit still. :)

tytho’s picture

Priority:Critical» Normal

Those who are getting the patch to work, are you setting the dependencies on the content type or the field collection? Even with the patch, the dependencies don't seem to be working when a field collection within a field collection depends on the value of another field. Here's my setup:

I have a field collection called "Main Content Well". Within this field collection, I have an image field, and another field collection called "Content Section" (the content manager can add as many as he wants of these). This content section has a select list, and different fields should appear/disappear based on the selected option. For example, if from the select list they select "Youtube video", all of the field except for the youtube video field should disappear. This works fine for single fields, but for field collections, they won't hide. Is this what this patch is fixing? Or is this another issue?

shapp’s picture

Has somebody already applied the patch successfully? I'm getting an error.

can't find file to patch at input line 5
Perhaps you should have used the -p or --strip option?
The text leading up to this was:
--------------------------
|diff --git a/conditional_fields.module a/conditional_fields.module
|index 31c76ec..60167ad 100644
|--- conditional_fields.module
|+++ conditional_fields.module
--------------------------
kenorb’s picture

Try removing a/ and /b in the 1st line.

smitherrama’s picture

Removed the 'a/' and 'b/', but I am getting the same error.

can't find file to patch at input line 5
Perhaps you used the wrong -p or --strip option?
The text leading up to this was:
--------------------------
|diff --git conditional_fields.module conditional_fields.module
|index 31c76ec..60167ad 100644
|--- conditional_fields.module
|+++ conditional_fields.module
--------------------------
shapp’s picture

Also tried it without the a/ and b/ but same problem here as #75

nkLiVF’s picture

try:

patch -p0 < file.patch

?

funkatron101’s picture

Applied the patch from #67. Re-uploaded the module. Saw no warnings, but also saw no change. What am I missing?

drupov’s picture

#72 - your explanation is confusing, maybe you can provide a screeenshot?

Anyway I just tested the #67-patch with field collections within field collections and everything works just fine.

Kudos to guys in the issue queue, that made it work. It's been a long fight.

aerrasti’s picture

Thank you for your explanation aendrew :) this thread solve my problems

calmher’s picture

Thank you so much for that very helpful fix #67 worked very well for me. Just re-uploading a cleaner patch, taking out the 'trailing whitespaces' error.

Kindly review if this works okay.

rbosscher’s picture

#81 patch is actually the only patch that was working for me.

However nested field collections with a dependency does still not seem to work on my site.
Is it in the scope of this patch or should I create a new issue?

sk2013’s picture

we tried #81. it doesn't work.
we applied the patch directly. without using git.
Any other possibilities is there?

rbosscher’s picture

Maybe it helps maybe not.

My steps were:
Uninstall module
Delete folder /sites/all/modules/conditional_fields
Download latest 7.x-3.x-dev
Install it
(I used patch manager)
Add the patch
Applied the patch

calmher’s picture

@in1ventures, could you try clearing your cache and see if that helps?

@rbosscher, re nested field collection, perhaps it will be cleaner to create a new issue for this?

sk2013’s picture

It worked for first field collection. But it is not working with nested field collection fields.
Any other possible solutions is there?please give us.

opensoft1’s picture

StatusFileSize
new30.92 KB
rbosscher’s picture

I've done a bit of searching.
Seems that nesting field collections issue is arround a while in 6.x versions as wel in 7.x

For: 7.x
The nested field collections are addressed in #1683136: Multiple Field Collections not displaying properly when using Conditional Fields but is pointing to this issue.
The issue starter of #1886628: How do i create nested dependent fields? is probably also refering to nesting field collections.

Not sure that this issue is about nesting fields, but could be a solution #1398482: you can specify parent relationships
As soon as I have some time I'll have a look at that one.

@opensoft1
On the module name field, did you filed it in as the module machine name?: "conditional_fields"
Your patch is being applied at sites/all/modules/contrib/conditional_fields while it probably should be applied on sites/all/modules/conditional_fields

opensoft1’s picture

we tried #88.
It doesn't work to us.

our requirement is

field collection 1
---field1
---field2
---field collection2
--- field1(checkbox)
--- field collection3

if clicked field1 of field collection2,field collection3 should be show otherwise it should be hide. This is our requirements. How can we achieve this through conditional fields?.
Is there any possible solution? Please guide us.

opensoft1’s picture

hi..... Is there any updates for this issue? pls kindly request you to give some solution for this issue

dafeder’s picture

Having the same issue: I can have a field collection dependent on another field in a content type. But if I try to create the same thing within another field collection, nothing happens; the dependent field collection is visible always and changing the dependee field seems to do nothing. Interestingly, if I have both of these situations on a form (a field collection dependent on a top-level field, and a nested field collection dependent on a field in the top-level field collection), both work as expected. Perhaps the required JS simply isn't being loaded when the form's only dependency is in a nested field collection. I don't see any errors in my browser's console.

kenorb’s picture

Status:Patch (to be ported)» Reviewed & tested by the community

Any progress on committing the #81 patch?

bigjim’s picture

Patch from #81 applied cleanly for me using git apply against the 2012-Nov-12 7.x-3.x-dev snapshot

jwilson3’s picture

Patch in #81; RTBC++ Thanks for all the hard work on this issue!

Regarding #86, #89, and #91 (supporting nested field collections) -- the patch is already pretty big and hard to review, so I suggest dividing it out into a second followup issue, so that it doesn't block this patch from forward progress and making it into the code-base as is.

Matthijs’s picture

I've created a patch for cross-entity dependees, see #1995516: Cross entity (Inline Entity form and Field collection) dependees. It's probably far from perfect, but it might be a good start!

dafeder’s picture

#81 worked for me for non-nested collections.

richardbyy’s picture

Category:bug» task
Priority:Normal» Critical
Status:Reviewed & tested by the community» Needs review
StatusFileSize
new46.04 KB

Hi, this version works fine with Field collection modules, and other modules, without bug when adding new field collection entries.

chris.jichen’s picture

I just tested on 'required' feature on field collection. It works on the front end (shows the asterisk * ) but It doesn't actually validate on the form submit.
The 'optional' feature doesn't work either. Correct me if i am wrong.
Thanks

mahyarss’s picture

i test #97 in admin form but not work for me. i am using "conditional fields" for "profile 2" with "field collection".

i created two field collection with many fields inside and add this fields in profile and can create dependencies but when change radio box not works "hide/show".

please help me how can i use field set in conditional fields module.

i searched and find many issues about this problem. but not found any solution or patch.

any body can help?

thanks

MO’s picture

StatusFileSize
new16.48 KB

Solving two issues with 2 patches

Issue #1 - This issue - Conditional Fields not working well with multi-value field collections.

Issue #2 - Nested field collections not responding as dependents on show/hide options (maybe others, but not tested)

To solve:

I combined #81 above with this other patch that solves for nested field collections.

Outcome:

It seems stable and working. I've attached the multi-patched version here. All you need to do is replace the .module file in the current dev release.

UPDATE

Please help roll this dual patch to a release: https://drupal.org/node/2088101

jonhattan’s picture

Priority:Critical» Major
Status:Needs review» Reviewed & tested by the community
StatusFileSize
new1.54 KB
new22.42 KB

+1 to jwilson3 words in #94:

Regarding #86, #89, and #91 (supporting nested field collections) -- the patch is already pretty big and hard to review, so I suggest dividing it out into a second followup issue, so that it doesn't block this patch from forward progress and making it into the code-base as is.

#81 is the latest working patch.

Patch in #41 introduces an extra + at line 294. None of the subsequent patches fixes it:

+++ b/conditional_fields.module
@@ -287,8 +289,8 @@ function conditional_fields_element_after_build($element, &$form_state) {
-      if (!isset($form['#conditional_fields'][$field['#field_name']]['dependents'][$id])) {
-        conditional_fields_attach_dependency($form, $field, array('#field_name' => $dependency['dependent']), $dependency['options'], $id);
+      if (!isset($form['#conditional_fields'][$field_parents_key][$field['#field_name']]['dependents'][$id])) {
++        conditional_fields_attach_dependency($form, $field, array('#field_name' => $dependency['dependent']), $dependency['options'], $field_parents_key, $id);
       }
     }
   }

Patch attached is #81 with this fix and a minor indentation fix. See interdiff.

I'm marking RTBC since #81 worked fine.

divined’s picture

81,100 and 101:

Notice: Undefined index: #field_parents in conditional_fields_element_after_build() (line 278 in conditional_fields.module).
Warning: Invalid argument supplied for foreach() in conditional_fields_flatten_array() (line 2008 in conditional_fields.module).

divined’s picture

And states not aplied for field.

divined’s picture

Update:

States are aplied for all field in field collection, but i can create node without fill this fields.

Empty validator not working.

jonhattan’s picture

Status:Reviewed & tested by the community» Needs work

#102 Notice: Undefined index: #field_parents in conditional_fields_element_after_build() (line 278 in conditional_fields.module).

@divined what field types are you using in your field collection?

divined’s picture

i have 3 fields:

1. selectlist (int) with 2 choices - "type of deal" (sell or rent)
2. field_collection with 2 subfields - "sell price"
- textfield (not required by default) - "price"
- selectlist (required by default) - "currency"
3. field_collection with 3 subfields - "rent price"
- textfield (not_required by default) - "price"
- selectlist (required by default) - "currency"
- selectlist (required by default) - "period of rent"

i have 4 dependencies rules:

1. "rent price" is visible when "type of deal" has value "2".
2. "rent price" is required when "type of deal" has value "2".
--
3. "sell price" is visible when "type of deal" has value "1".
4. "sell price" is required when "type of deal" has value "1".

---
Visible rule work as well.
Required rule mark not_required fields as required, but system not validate empty values
Required rule mark required fields with double asterisk

Jody Lynn’s picture

The patch in #101 is working well for me. Thank you all.

jonhattan’s picture

Status:Needs work» Needs review

@divined the problem you describe in #106 is not related to this issue. This issue is about multivalued field_collection fields.

Your setup fails in the same way with or without the patch here. You may open a new issue for the bugs with required fields within field_collection.

I'm unable to reproduce #105, thus moving back to needs review.

jonhattan’s picture

Issue summary:View changes

Fixed spelling

yannickoo’s picture

The patch from #101 does not work anymore and re-rolling is not funny but finally I did it :) I also uploaded a patch without all the whitespaces so that it is cleaner to see what the patch actually does.

BTW the patch works fine, thank you guys for the work!

kumkum29’s picture

Hello,

i get an error when i apply this patch (109) with git:

error: patch failed:conditional_fields.module:428

Thanks for your help.

wwwjaylee’s picture

#109 worked for me. Thank you.

yannickoo’s picture

I could apply the patch without any errors:

➜  conditional_fields git:(7.x-3.x) curl -O https://drupal.org/files/issues/conditional_fields-fixed_multiple_field_collection_fields-1464950-109.patch
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100 22861  100 22861    0     0   7915      0  0:00:02  0:00:02 --:--:--  7915
➜  conditional_fields git:(7.x-3.x) ✗ git apply conditional_fields-fixed_multiple_field_collection_fields-1464950-109.patch
➜  conditional_fields git:(7.x-3.x) ✗
nevergone’s picture

Patch rerolled (commit: 23eac31) and interdiff added.

yannickoo’s picture

Why did you re-roll the patch, the patch from #109 applies cleanly:

➜  conditional_fields git:(7.x-3.x) ✗ git apply -v conditional_fields-fixed_multiple_field_collection_fields-1464950-109.patch
Checking patch conditional_fields.module...
Applied patch conditional_fields.module cleanly.
nevergone’s picture

@yannickoo:
Ok, no-test patch is failed:

conditional_fields (7.x-3.x %)$ git apply -v conditional_fields-fixed_multiple_field_collection_fields-1464950-109-no-whitespaces-do-not-test.patch
Checking patch conditional_fields.module...
error: while searching for:
  $state_handlers = conditional_fields_states_handlers();

  // Cycle all dependents.
  foreach ($form['#conditional_fields'] as $dependent => $dependent_info) {
      $states = array();

      if (empty($dependent_info['dependees'])) {
        continue;
      }

      $dependent_location = array_merge($dependent_info['field_parents'], array($dependent));
      $dependent_form_field = drupal_array_get_nested_value($form, $dependent_location);

error: patch failed: conditional_fields.module:428
error: conditional_fields.module: patch does not apply

yannickoo’s picture

The "no-test" patch was just the patch without whitespaces so that people can better see what the patch actually does.

kumkum29’s picture

Hello yannickoo,

After several attempts to patch I always get an error:

$git apply -v conditional_fields-fixed_multiple_field_collection_fields-1464950-109.patch
Checking patch conditional_fields.module...
error: while searching for:
    return $element;
  }

  // Attach dependent.
  if (isset($dependencies['dependents'][$field['#field_name']])) {
    foreach ($dependencies['dependents'][$field['#field_name']] as $id => $dependency) {
      if (!isset($form['#conditional_fields'][$field['#field_name']]['dependees'][$id])) {
        conditional_fields_attach_dependency($form, array('#field_name' => $dependency['dependee']), $field, $dependency['options'], $id);
      }
    }
  }

error: patch failed: conditional_fields.module:259
error: conditional_fields.module: patch does not apply

I also tried to patch the module at hand but I also have an error in the code.
Can you provide us the file patched?

Thank you for your help.

danielphenry’s picture

patch in 109 does not apply. using latest 7.x-3.x dev. says segment #6 (the largest section) doesn't apply.

danielphenry’s picture

Status:Needs review» Reviewed & tested by the community

So I got the patch in 109 to apply when I checked out the repo directly then applied the patch via git. So it appears it does still apply. It also works. Can this get checked in?

loze’s picture

confirming patch in 109 works. thanks!

jeffglenn’s picture

The patch in 109 works in Field Collections but breaks other Conditional Fields on my content type. When I go to save content in a Conditional Field that is not within a Field Collection the content is not saved. When I revert the module back to the original state (before the patch), everything works fine but of course I can't have Conditional Fields in Field Collections.

Anyone else run into this?

rudy.barrett’s picture

I get the error with patch #109 using Conditional Fields 7.x-3.0-alpha1 inside of Field Collections:
Hunk #1 succeeded at 272 (offset 13 lines).
Hunk #2 succeeded at 289 (offset 13 lines).
Hunk #3 succeeded at 368 (offset 13 lines).
Hunk #4 succeeded at 399 (offset 13 lines).
Hunk #5 succeeded at 414 (offset 13 lines).
Hunk #6 FAILED at 443.
Hunk #7 succeeded at 1001 (offset 15 lines).
Hunk #8 succeeded at 1984 (offset 9 lines).

jeffglenn, I continue to be unable to use conditional fields with multiple entries inside of a field collection

Jody Lynn’s picture

Here's a fun one:

If you have a multiple field collection inside of another (multiple) field collection, with the patch in 109, the inner field collections after the first one does not have working conditional fields.

So if you have field collection foo1 which contains collections bar1 and bar2, and you have field collection foo2 which contains collections bar3 and bar4, the conditional fields work properly in bar1 and bar 3 but not in bar2 or bar4...

danielphenry’s picture

rudongg: you need to pull the repo from git and then patch it. It will not work on any of the release branches.

Jody Lynn: while this indicates their are a few more bugs to fix this patch is a clear step forward I think it's important this patch gets put in asap. Then a new issue can be opened for that more specific case.

GBain22’s picture

I'm getting the same issues as rudongg - Jody Lynn - how can you do that if you're not using Git? I simply downloaded the patch and in SSH I applied "patch -p1 mypatchfile.patch" and resulted in the Hunk #6 FAILED at 443.

Is there a way around this if you're not using git?

rudy.barrett’s picture

Thanks danielson, the patch applied cleanly. For others, here is the workflow:
1. git clone --branch 7.x-3.x http://git.drupal.org/project/conditional_fields.git
2. wget https://drupal.org/files/issues/conditional_fields-fixed_multiple_field_...
3. git apply -v conditional_fields-fixed_multiple_field_collection_fields-1464950-109.patch

response:
Checking patch conditional_fields.module...
Applied patch conditional_fields.module cleanly.

Thanks again for the patch!

jeffglenn’s picture

I can confirm that pulling branch 7.x-3.x from git then using the patch works. I can now have Conditional Fields inside and outside of Field Collections and all works and content is saved.

Thanks rudongg for detailing!

capellic’s picture

Thanks, rudongg! I have provided the same steps that are in #127, but wrapped them in the "code" tag as as not to have the URL truncated and added the change directory as a step. Be sure you are in the target directory (sites/all/modules/contrib) before running the git clone command. If you don't have wget, go to the URL in the browser, download and then put the patch file in your conditional_fields folder -- you may have to remove the ".txt" at the end of the file name.

1. git clone --branch 7.x-3.x http://git.drupal.org/project/conditional_fields.git
2. cd conditional_fields
3. wget https://drupal.org/files/issues/conditional_fields-fixed_multiple_field_collection_fields-1464950-109.patch
4. git apply -v conditional_fields-fixed_multiple_field_collection_fields-1464950-109.patch

Patch applies cleanly, would love to see this in Dev! Thanks all!

capellic’s picture

Starting to see these notices/warnings after applying patch:

Notice: Undefined variable: options in conditional_fields_form_after_build() (line 558 of /Users/stephenm/Sites/devdesktop/capellicfree-dev/docroot/sites/all/modules/contrib/conditional_fields/conditional_fields.module).

Notice: Undefined variable: behaviors in conditional_fields_form_after_build() (line 572 of /Users/stephenm/Sites/devdesktop/capellicfree-dev/docroot/sites/all/modules/contrib/conditional_fields/conditional_fields.module).

Warning: in_array() expects parameter 2 to be array, null given in conditional_fields_form_after_build() (line 572 of /Users/stephenm/Sites/devdesktop/capellicfree-dev/docroot/sites/all/modules/contrib/conditional_fields/conditional_fields.module).

Notice: Undefined variable: options in conditional_fields_form_after_build() (line 558 of /Users/stephenm/Sites/devdesktop/capellicfree-dev/docroot/sites/all/modules/contrib/conditional_fields/conditional_fields.module).

Notice: Undefined variable: behaviors in conditional_fields_form_after_build() (line 572 of /Users/stephenm/Sites/devdesktop/capellicfree-dev/docroot/sites/all/modules/contrib/conditional_fields/conditional_fields.module).

Warning: in_array() expects parameter 2 to be array, null given in conditional_fields_form_after_build() (line 572 of /Users/stephenm/Sites/devdesktop/capellicfree-dev/docroot/sites/all/modules/contrib/conditional_fields/conditional_fields.module).

gmario’s picture

Hi,

I have applied the patch #109 with no errors. But this patch have introduced a bug in my form.

In my form (to add a node) I have a checkbox that controls if a collection fields must be visible or not. The collection fields is a multivalued field and into it there is a combo box that controls if a textbox is visible or not. The patch solved the dependencies problem into the field collection in case of more then one value (combo box - textbox), but now, when the form is submitted, the node created have the field collection always empty.

There is anybody that can point my on the right direction on where to check, in the trying to solved this bug?

update: every field collection present in content type and that is dependent from another field's state, it is not being saved in the node being created.

I have a content type, named A, with a field collection, named fc1. the fc1 field is dependent from another field (checkbox) named cb1. When cb1 is checked fc1 become enabled so that it is possible to fill its fields.

When the form it is submitted, the node is created but with a empty fb1 field.

does anyone can help?

tnks a lot
gmario

gmario’s picture

StatusFileSize
new22.53 KB
PASSED: [[SimpleTest]]: [MySQL] 160 pass(es).
[ View ]

Hi,

after a bit of debugging, i've found the reason of misbehaviour explained in the previous post. The patch of comment #109 inserts a bug

the code in conditional_fields.module before to apply the patch is

<?php
538
539       
// Add validation callback to element.
540        _conditional_fields_element_add_property($dependent_form_field, '#element_validate', 'conditional_fields_dependent_validate', 'append');
541      }
542
?>

after applied the patch

<?php
540       
}
541
542       
// Add validation callback to element.
543        _conditional_fields_element_add_property($dependent_form_field, '#element_validate', 'conditional_fields_dependent_validate', 'append');
544
?>

the function call _conditional_fields_element_add_property is put outside the brach "else" of "if" statement at row 497.

in attachment the new patch.

a si biri
gmario

dahousecat’s picture

Patch #132 worked for me but I had to apply it to latest dev release (7.x-3.x-dev 2014-Jan-06) to get it to work.

pedromvpg’s picture

pianomansam’s picture

I can confirm that patch in #132 works as intended!

balsama’s picture

+1 for patch in #132. Applied cleanly against dev version from 06JAN2014 and works as expected.

sketman’s picture

The same here, patch in #132 worked correctly.

Lukas von Blarer’s picture

Works great. Thanks!

khasmir’s picture

Patch #132 apply it to latest dev release (7.x-3.x-dev 2014-Jan-06) and starting to see these notices/warnings after applying patch:

Notice: Undefined variable: options in conditional_fields_form_after_build() (line 558 of /home/khasmir/www/meif/sites/all/modules/custom/conditional_fields/conditional_fields.module).
    Notice: Undefined variable: behaviors in conditional_fields_form_after_build() (line 572 of /home/khasmir/www/meif/sites/all/modules/custom/conditional_fields/conditional_fields.module).
    Warning: in_array() expects parameter 2 to be array, null given in conditional_fields_form_after_build() (line 572 of /home/khasmir/www/meif/sites/all/modules/custom/conditional_fields/conditional_fields.module).

Does anyone can help?
Thanks

leewillis77’s picture

Hi,

We've applied the patch in #132 but are experiencing the warnings originally reported in #102, specifically we're getting:

Notice: Undefined index: #field_parents in conditional_fields_element_after_build() (line 262 of /var/www/html/sites/all/modules/patched/conditional_fields/conditional_fields.module).
Warning: Invalid argument supplied for foreach() in conditional_fields_flatten_array() (line 1986 of /var/www/html/sites/all/modules/patched/conditional_fields/conditional_fields.module).

The field that's throwing the error is a views reference field on the main node. It appears that this field does not have #field_parents set at all. We don't have any dependencies set involving this field, so not sure if conditional fields needs to process the field.

I suspect the bug could be worked around in our case by moving the
$field_parents_key = conditional_fields_flatten_array($field['#field_parents']);
inside the

if (isset($dependencies['dependents'][$field['#field_name']])) {
and
if (isset($dependencies['dependees'][$field['#field_name']])) {

blocks, but not sure if that's the right fix or not.

leewillis77’s picture

Status:Reviewed & tested by the community» Needs work

Setting back to needs work, as these warnings aren't thrown without the patch. Happy to provide further info, or test alternative approaches / patches.

moertle’s picture

After applying the patch #132 I get a PHP-Error:
Error: syntax error, unexpected '}' .... in conditional_fields\conditional_fields.module on line 670

After removing the closing brace (} at line 643 (nearby $has_states = TRUE;), it seems to work as expected.

What did I wrong?

UPDATE:
my quickfix was wrong, is it a good idea to use the DEV Version for D7? The patch seems to be applied there

UPDATE II:
well, I'm sorry, just realized now that the patch IS for the DEV Version, everything ok. Thanks for the patch, it workes fine.

guillaumev’s picture

The patch is working for me. Thanks !

capellic’s picture

Working well for me, thanks to all who worked on this.

SocialNicheGuru’s picture

I am getting the same errors as in 139.

https://www.drupal.org/node/1464950#comment-8650803

jamiehollern’s picture

Patch in 132 works for me, however I can only add a single dependency to any collection as only one works.

Edit to say that I'm also seeing the error notices reported in 139 and 140.

AndyBalloon’s picture

I can confirm, patch 132 works for me.

dnlmzw’s picture

I'm experiencing the same as #146. Patch works and I can now use it together with Field Collections, but Conditional Fields only works on the first collection in a Field Collection when the "Number of values" is set to "Unlimited".

So - In reality the issue that was initially described still persists. Has anyone found a way around this issue?

ocastle’s picture

It also works only on the first field collection item for me too. Its for both "Unlimited" and anything >1. (Checked both alpha and dev release)

I've also got the setup that a field collection within this field collection should only be visible when a select box is a certain value, but this field doesn't get hidden. -- This has been patched here: https://www.drupal.org/node/1648128

Going to be looking mainly for a solution to the multiple field collection item problem - I could probably use a different setup on the child field collection for now.

RajabNatshah’s picture

Part working .. #13 droath's patch is working for me for the --dev.
( No It's not working )!!!!!

ocastle’s picture

Patch #132 worked for me against the Dev Release and fixed all field collection items (Unlimited and Limited > 1).

RajabNatshah’s picture

StatusFileSize
new26.65 KB
PASSED: [[SimpleTest]]: [MySQL] 160 pass(es).
[ View ]

I do have this patch #153 working from #100 ..

RajabNatshah’s picture

Status:Needs work» Needs review
RajabNatshah’s picture

StatusFileSize
new8.99 KB
FAILED: [[SimpleTest]]: [MySQL] 160 pass(es), 0 fail(s), and 297 exception(s).
[ View ]

A better patch #155 To have the fix in nested entity reference and inline entity forms

Status:Needs review» Needs work
shawnrosspeters’s picture

Patch #155 seems to almost be there, but couple quick questions:

  1. What version of Entity API and Field Collection should we use with this?
  2. What, if any, patches should be applied to the above modules?

I just want to be sure we're using the most stable combination as patching might be necessary sometimes but always increases the chances of stuff breaking when trying to perform updates to the site. Thanks all!

RajabNatshah’s picture

Patch #153 works in a perfect way.
But if you have a nested entity reference inside the field collection.. with Inline entity form you will run into some problems with conditional fields ( This is when patch #155 do the work ).

I suggest patch #153 can work if the patch going to make it to the Module. Note .. It's the attachment of MO's comment #100. It took me long time testing all this list of patches.

Rewarding :)

cobaltje’s picture

Is there a possibility that this come in a new module update?
I don't have the possibilitys do execute this patch :( I need a module update for this.

shawnrosspeters’s picture

Has anyone had success in the following setup because I've tried all patches available and nothing works.

Page Type
- Field Collection (unlimited)
-- Select List (Dependee Trigger)
-- Field Collection 1 (limit 1) (Dependent 1)
-- Field Collection 2 (limit 1) (Dependent 2)
-- Field Collection 3 (limit 1) (Dependent 3)

The idea here is that when you add a new "Page", you can add an unlimited number of rows and each row allows you to select from the trigger field and thereby making the dependent selected visible.

There's been a LOT of work to get Conditional Fields and Field Collection to play nice but I'm just wondering if something's missing here.

  1. Should the above mentioned setup work using the latest patch?
  2. What version of Entity API should be used?
  3. What version of Field Collection should be used?

Thanks everyone!

Status:Needs review» Needs work
RajabNatshah’s picture

Ok .. Seems that we still need more fixing for this issue to work with other modules too.
It's had been a long time that this issue is not fixed yet.

dnlmzw’s picture

Same as #152.

Patch 155 works for me after I implemented the 7.x-3.x-dev version. (Updating from "7.x-3.0-alpha1")

This was my first time applying a patch. I struggled a bit with understanding how to make it work and thought I'd share how I did (MacOSX):

Download and backup
> Make a copy of your original "conditional_fields" folder (Located in "/sites/all/modules/conditional_fields")
Attention: The copy cannot be located in the "modules"-folder. It will conflict with the new version, even when named differently.

> Download the "7.x-3.x-dev"-version of the "conditional_fields"-module
> Overwrite the old "conditional_fields"-module with the new "dev"-version

This might cause problems for some people, but worked for me updating from "7.x-3.0-alpha1".

Navigating using the Terminal

> Open Terminal (You can find it using Spotlight)
> Write "cd " (Make sure you have a space after cd)
> Drag the "conditional_fields" folder (located in "/sites/all/modules/conditional_fields") and release it into the Terminal window
> Press enter  (This changes the directory Terminal will execute the script in)

Applying the patch

> Download patch 155 (See answer #161)
> Go back to Terminal
> Write "patch < " (Make sure you have a space after <)
> Drag the patch file (The one you just downloaded) and release it into the Terminal window
> Press enter

This solved the problem for me. I have not yet experienced any side-effects, but can't promise this will work for everyone.

jyraya’s picture

The patch #155 does not work well in my context.

I applied it on the module version 7.x-3.0-alpha1 with Field collection 7.x-1.0-beta7 and Entity API 7.x-1.5.
I got the same exception at the Simple test met while testing automatically the patch; I.E.:
Notice: Undefined index: field_video in conditional_fields_evaluate_dependencies() (line 1026 of C:\xampp183\htdocs\...\sites\all\modules\contrib\conditional_fields\conditional_fields.module).
Warning: Invalid argument supplied for foreach() in conditional_fields_evaluate_dependencies() (line 1029 of C:\xampp183\htdocs\...\sites\all\modules\contrib\conditional_fields\conditional_fields.module).
Notice: Undefined index: field_video in conditional_fields_evaluate_dependencies() (line 1050 of C:\xampp183\htdocs\...\sites\all\modules\contrib\conditional_fields\conditional_fields.module).

These messages, I got them for each dependee fields defined in my field collection and for each contributed field collection item.

I tried after with the latest dev version and I got the same result.

My case is the following:
Field Collection item

  • text field
  • text field
  • list (Dependee Trigger: in function of select list item, one of the field below is shown and others are hidden)
    • entity reference (with Entity Reference View Widget 7.x-2.0-rc2) (dependent field 1)
    • File (with File entity) (dependent field 1)
    • Image (multi-value and with File entity) (dependent field 1)

The field collection is unlimited.

I started to debug the code and discovered that this:

function conditional_fields_evaluate_dependencies($dependent, $form, $form_state) {
  $dependencies = $form['#conditional_fields'][$dependent['#field_name']]['dependees'];

We retrieve "dependees" of a field by using the field name value but $form['#conditional_fields'] has the following structure:

$form['#conditional_fields'] {
     ["root:field_collection_field_name:und:0:"] {
           [field_name_1],
           [field_name_2],
            ...
     },
     ["root:field_collection_field_name:und:1:"] {
           [field_name_1],
           [field_name_2],
            ...
     },
     ...
}

What is the logic behind "root:field_collection_field_name:und:1:"?
What is the key if I have a field collection inside a field collection?

jlongbottom’s picture

#132 worked for me against latest dev version

deepakaryan1988’s picture

#155 worked for me. I used latest dev version and applied this patch with field collection 7.x-1.0-beta7.

nimoatwoodway’s picture

#132 works for me against latest dev version. Many thanks!

SocialNicheGuru’s picture

155 applies to the Jan/14 dev version
It has to be the first patch applied to the module if there are other patches to be applied.

Update 1:
I am getting this too::
https://www.drupal.org/node/1464950#comment-9177749

I have a field_collection
within the field collection are two other field collections being controlled by a list field.
There is an issue with nesting field collections and using this module

Status:Needs work» Needs review

Status:Needs review» Needs work
asif_khan’s picture

patch 153 works for me with this field_attach_form() overwrites #entity_type and #bundle to field collection
thanks
myset up is
content type
----fields
----field-collection
---- --------fields
---- --------field collection
-- ------ --------field a--select list
-- ------ --------field b-- text--depends on field a's specific value
-- ------ --------field c--text--depends on field a's specific value

Status:Needs review» Needs work

Status:Needs review» Needs work
edmund518’s picture

Wait for updates, apply 155, but it fails.

patching file conditional_fields.module
Hunk #1 succeeded at 213 (offset 13 lines).
Hunk #2 succeeded at 271 (offset 13 lines).
Hunk #3 FAILED at 288.
Hunk #4 FAILED at 305.
Hunk #5 FAILED at 384.
Hunk #6 FAILED at 415.
Hunk #7 FAILED at 430.
Hunk #8 succeeded at 461 (offset 15 lines).
Hunk #9 succeeded at 475 (offset 15 lines).
Hunk #10 succeeded at 568 (offset 15 lines).
Hunk #11 succeeded at 661 (offset 17 lines).
Hunk #12 FAILED at 1210.
Hunk #13 FAILED at 1989.
Hunk #14 succeeded at 2023 with fuzz 2 (offset 29 lines).
7 out of 14 hunks FAILED -- saving rejects to file conditional_fields.module.rej

Status:Needs work» Needs review

Status:Needs review» Needs work
ex0r’s picture

Still no fix to this ? There are bunches of patches released and none of them seem to work >.<

Marfio’s picture

#153 working form me

Field Collection - 7.x-1.0-beta8
Conditional Fields - 7.x-3.0-alpha1

steven_ght’s picture

Hey Marfio,

Could you tell us how you applied the patch ?
I'm running the same versions as you (Field Collection and Conditional Fields) but the patch doesn't apply on the code.
I tried to apply it with Drush (make) but the build fails (patch doesn't apply error) so I tried to clone the module's repository and apply the patch manually but errors keep on being thrown.

Thanks !

EDIT : The problem started to occure anew while upgrading core from (Pressflow) 7.32 to 7.34

aarefjev’s picture

Steven_ght:
same problem here - just installed patch manually, still not working. Pain in the ass really....
Versions used :
Field Collection - 7.x-1.0-beta8
Conditional Fields - 7.x-3.0-alpha1
Drupal Core: 7.32

steven_ght’s picture

aarefjev:

We've tried several things (core downgrade, modules downgrades etc etc ...) ... We've come up with a working codebase, it seems that Asset is the reason of the problem. After upgrading it to the latest available version (not the latest release) by cloning its repository, our problem seems solved.

EDIT : We were using the 1.0-beta4 version

maximefc’s picture

I got it working !

Conditional Fields 7.x-3.0-alpha1+12-dev
Field collection 7.x-1.0-beta8

Patch 153 ;)

Thanks RajabNatshah !

odegard’s picture

Can confirm that Patch in #153 works. I installed latest dev (2015 jan 06) and used it successfully with multifield.

amitgoyal’s picture

Status:Needs work» Needs review
StatusFileSize
new7.42 KB
FAILED: [[SimpleTest]]: [MySQL] Unable to apply patch conditional_fields-fixed_multiple_field_collection_fields-1464950-190.patch. Unable to apply patch. See the log in the details link for more information.
[ View ]

Re-roll of #155 which applies cleanly and fixes following issues,

- #155 leaves extra '+' in the start of the line.
- #155 causes duplicate hook_js_alter().

Status:Needs review» Needs work
amitgoyal’s picture

Status:Needs work» Needs review
StatusFileSize
new7.21 KB
FAILED: [[SimpleTest]]: [MySQL] 160 pass(es), 0 fail(s), and 297 exception(s).
[ View ]

Recreated the #190 patch as there was path issue w.r.t. creation of patch.

Status:Needs review» Needs work
mrvinch’s picture

#192 Works like a charm. Thank you for the work amitgoyal and all others above who contributed.

My case was a dependent field collection that was nested inside another collection. The triger was a select list in the parent collection.

Using 7.x-3.x-dev 2014-Jan-06

paulmartin84’s picture

StatusFileSize
new8.29 KB
PASSED: [[SimpleTest]]: [MySQL] 160 pass(es).
[ View ]

The hiding and showing of fields etc. was working correctly for me, but after saving the node I was experiencing the same issues mentioned in #165 and #171. This seems to fix that issue.

goblin29’s picture

#195 works for me. Thanks paul I am using
Conditional Fields : 7.x-3.0-alpha1
Field Collection: 7.x-1.0-beta8

balsama’s picture

Status:Needs work» Needs review

Test #195

ankaiyuan’s picture

Thanks #195 It`s work.

Ritch’s picture

Conditional Fields : 7.x-3.0-alpha1+15-dev
Field Collection : 7.x-1.0-beta8

Thank's #195 works for me.