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

CommentFileSizeAuthor
#385 conditional_fields-fixed_multiple_field_collection_fields-1464950-385.patch26.16 KBjuampynr
#384 conditional_fields-fixed_multiple_field_collection_fields-1464950-384.patch32.84 KBslv_
#368 conditional_fields-fixed_multiple_field_collection_fields-1464950-368.patch25.3 KBPancho
#368 1464950_341-368_interdiff.txt1.26 KBPancho
#366 conditional_fields-fixed_multiple_field_collection_fields-1464950-366.patch25.91 KBPancho
#366 1464950_341-366_interdiff.txt1.83 KBPancho
#362 conditional_fields-fixed_multiple_field_collection_fields-1464950-362.patch32.95 KBBramDriesen
#360 conditional_fields-fixed_multiple_field_collection_fields-1464950-360.patch32.95 KBBramDriesen
#341 interdiff-1464950-335-341.txt4.21 KBgmarchev
#341 conditional_fields-fixed_multiple_field_collection_fields-1464950-341.patch26.09 KBgmarchev
#335 interdiff-ignore-whitespace-1464950-333-335.txt901 bytesjojonaloha
#335 interdiff-1464950-333-335.txt3.53 KBjojonaloha
#335 conditional_fields-fixed_multiple_field_collection_fields-1464950-335.patch26.33 KBjojonaloha
#333 interdiff-331-333.txt1.32 KBBR0kEN
#333 1464950-333.patch24.76 KBBR0kEN
#331 conditional_fields_multifield-1464950-331.patch23.95 KBBrandonian
#328 inderdiff.txt1.92 KBdrclaw
#328 conditional_fields-1464950-328.patch23.47 KBdrclaw
#323 conditional_fields-1464950-323.patch24.81 KBcgoffin
#310 interdiff.txt1.28 KBb_sharpe
#310 conditional_fields-1464950-310.patch24.84 KBb_sharpe
#303 integrate-some-patch.patch34.03 KBkespinosa05@gmail.com
#279 interdiff.txt22.93 KBstefan.r
#275 conditional_fields-fixed_multiple_field_collection_fields-1464950-276.patch24.76 KBpeterpoe
#273 conditional_fields-fixed_multiple_field_collection_fields-1464950-275.patch24.76 KBpeterpoe
#261 conditional_fields-fixed_multiple_field_collection_fields-1464950-261.patch8.24 KBjoshf
#260 conditional_fields_patch_test.tar_.gz2.57 KBjoshf
#232 interdiff-1464950-219-229.txt2.89 KBzestagio
#230 interdiff-1464950-228-229.txt1.32 KBzestagio
#229 conditional_fields-support-for-multiple-field-collection-fields-1464950-229.patch23.24 KBzestagio
#228 conditional_fields-support-for-multiple-field-collection-fields-1464950-228.patch23.22 KBzestagio
#219 interdiff-218-219.txt761 bytesstefan.r
#219 1464950-219.patch22.51 KBstefan.r
#218 1464950-218.patch22.51 KBstefan.r
#207 conditional_fields_fixed_multiple_field_collection_fields_1464950-63_0.patch22.51 KBkenorb
#195 conditional_fields-fixed_multiple_field_collection_fields-1464950-195.patch8.29 KBpaulmartin84
#192 conditional_fields-fixed_multiple_field_collection_fields-1464950-192.patch7.21 KBamitgoyal
#190 conditional_fields-fixed_multiple_field_collection_fields-1464950-190.patch7.42 KBamitgoyal
#155 conditional_fields-fixed_multiple_field_collection_fields-1464950-155.patch8.99 KBRajab Natshah
#153 conditional_fields-fixed_multiple_field_collection_fields-1464950-153.patch26.65 KBRajab Natshah
#132 conditional_fields-fixed_multiple_field_collection_fields-1464950-132.patch22.53 KBgmario
#114 interdiff.txt7.82 KBnevergone
#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-no-whitespaces-do-not-test.patch9.78 KByannickoo
#109 conditional_fields-fixed_multiple_field_collection_fields-1464950-109.patch22.33 KByannickoo
#101 conditional_fields-fixed_multiple_field_collection_fields-1464950-101.patch22.42 KBjonhattan
#101 interdiff-1464950-81-101.txt1.54 KBjonhattan
#100 conditional_fields_module.zip16.48 KBMO-2
#97 conditional_fields.zip46.04 KBrichardbyy
#87 Capture.PNG30.92 KBopensoft1
#81 conditional_fields-fixed_multiple_field_collection_fields-1464950-81.patch22.45 KBcalmher
#67 conditional_fields_fixed_multiple_field_collection_fields_1464950-62.patch22.5 KBkenorb
#62 conditional_fields_fixed_multiple_field_collection_fields_1464950-62.patch22.5 KBarosboro
#42 conditional_fields_fixed_multiple_field_collection_fields_1464950-42.patch22.69 KBjoel_osc
#41 conditional_fields_fixed_multiple_field_collection_fields_1464950-41.patch22.7 KBjoel_osc
#28 conditional_fields_fixed_multiple_field_collection_fields_1464950-28.patch23.39 KBguidotti
#18 conditional_fields_fixed_multiple_field_collection_fields_1464950-18.patch15.26 KBbigjim
#13 conditional_fields_fixed_multiple_field_collection_fields_1464950-13.patch19.53 KBdroath
#6 conditional_fields_fixed_multiple_field_collection_fields_1464950-5-1.patch21.78 KBdroath
#5 conditional_fields_fixed_multiple_field_collection_fields_1464950-5.patch21.93 KBdroath
Support from Acquia helps fund testing for Drupal Acquia logo

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
FileSize
21.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.

bryancasler’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
FileSize
15.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.

Anonymous’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.

Anonymous’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

aendra’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 ;)

aendra’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
FileSize
22.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)
aendra’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. :)

Anonymous’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

FileSize
30.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
FileSize
46.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

mahyarsbt’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-2’s picture

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
FileSize
1.54 KB
22.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.

jay.lee.bio’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

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

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


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


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.

andy.alexander’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.

Rajab Natshah’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).

Rajab Natshah’s picture

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

Rajab Natshah’s picture

Status: Needs work » Needs review
Rajab Natshah’s picture

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!

Rajab Natshah’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 work » Needs review

Status: Needs review » Needs work
Rajab Natshah’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 work » Needs review

Status: Needs review » Needs work

Status: Needs work » Needs review

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

gmaxime’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
FileSize
7.42 KB

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
FileSize
7.21 KB

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

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

sosyuki’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.

michielkenis’s picture

Conditional Fields: 7.x-3.0-alpha1
Field collection: 7.x-1.0-beta8

Patch #195 is working too

cassien’s picture

Conditional Fields: 7.x-3.0-alpha1
Field collection: 7.x-1.0-beta8

Patch #195 is passing but is not working

I have that fatal error :
Fatal error: Call to undefined function conditional_fields_flatten_array() in C:\wamp\www\ryser\sites\all\modules\conditional_fields\conditional_fields.module on line 278

Any idea ?

clint.beacock’s picture

Conditional Fields: 7.x-3.0-alpha1
Field collection: 7.x-1.0-beta8

Patch #195 is working for me too, but I do get the following warnings come up:

Notice: Undefined index: #field_parents in conditional_fields_element_after_build() (line 278 of /vagrant/www/niagara-drupal/sites/all/modules/contrib/conditional_fields/conditional_fields.module).
Warning: Invalid argument supplied for foreach() in conditional_fields_flatten_array() (line 2022 of /vagrant/www/niagara-drupal/sites/all/modules/contrib/conditional_fields/conditional_fields.module).

csedax90’s picture

#195 with Field collection 7.x-1.0-beta8+6-dev is working correctly... no errors or warnings

Pryrios’s picture

#195 also works for me.

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

kenorb’s picture

Status: Needs review » Reviewed & tested by the community
kenorb’s picture

Re-applying patch against dev, the last one wasn't applying cleanly anymore, therefore this patch needs to be re-tested.

jlbellido’s picture

#207 works well for :

- Contional fields : 7.x-3.0-alpha1+15-dev (Current dev version)
- Field collection : 7.x-1.0-beta8

Thanks a lot for your work in this issue!

This should be a RTBC again?

kenorb’s picture

Status: Needs review » Reviewed & tested by the community
MustangGB’s picture

RTBC from me too.

Blanca.Esqueda’s picture

Hi,

patch on #207 works for me... but I had to do some updates to the patch:

  1. Removed one plus sign:
    Line 29 has double ++
  2. Added a line after Line 155:
    - unset($behaviors[CONDITIONAL_FIELDS_FIELD_EDIT_RESET_UNTRIGGERED]);
  3. Replaced line 332:
    - $behavior($form, $form_state, $dependent, $dependent_info);
    By
    - // Custom behaviors are callbacks.
    - if (function_exists($$behavior)) {
    - $$behavior($form, $form_state, $dependent, $dependent_info);
    - }
likewhoa’s picture

Status: Reviewed & tested by the community » Needs work

@Blanca care to re-roll patch?

mmartinov’s picture

Status: Needs work » Reviewed & tested by the community

As stated in #209, the patch from #207 applies cleanly on conditional_fields-7.x-3.0-alpha1+15-dev which is the current dev version.

I don't think a re-roll is needed.

stefan.r’s picture

Applies against HEAD so re-roll should not be needed. Queuing another test to confirm.

likewhoa’s picture

@mmartinov @stefan.r sure it applies cleanly but @Blanca suggest it needs works and seeing how she saw that it had an extra '+' and a couple of others things this is why I requested a re-roll.

stefan.r’s picture

FileSize
22.51 KB

Those changes refer to code that is not in dev anymore so I think those may just have been the steps needed to apply it to an older version.

Anyway, a reroll is attached just in case.

stefan.r’s picture

Status: Reviewed & tested by the community » Needs review
FileSize
22.51 KB
761 bytes

Hmm, that double + definitely didn't belong there though

Blanca.Esqueda’s picture

The version of conditional fields that I'm using is: "7.x-3.0-alpha1"
Sorry I didn't add the note before. I guess I needed to do some changes because I have "7.x-3.0-alpha1" instead of "7.x-3.0-alpha1+15-dev".

As commented the patch suggested is working.

dramblys’s picture

hey everyone!

I'm using '7.x-3.0-alpha1' of Conditional fields, tried to apply patches above (..219, and #207 with #212 changes). But, for some reason, it either says error on 414 line (or smth like this for 219 patch. my guess it's because i'm not using the "dev" version) or it says 0 changes (for edited #207 patch).

Could anyone advise. I'm pretty new to whole patching thing, but it seems I haven't done any mistakes in the process.

Also I'd like to add, that the logic of condition works in my case, but the JS (hide/show) in additional (second, third and so on) field collections is not working.

And thank you in advance for your replies.

Pryrios’s picture

I'm using '7.x-3.0-alpha1' of Conditional fields, tried to apply patches above (..219, and #207 with #212 changes). But, for some reason, it either says error on 414 line (or smth like this for 219 patch. my guess it's because i'm not using the "dev" version) or it says 0 changes (for edited #207 patch).

The pacth is applied to the last dev version (7.x-3.0-alpha1+15-dev) which is different from yours. Look at comment in #212 which has the same case as you (7.x-3.0-alpha1) for correcting your issues.

Basically, you can either download the patch in #207 and change it according to #212 or download version "7.x-3.0-alpha1+15-dev" and apply the patch "as is" in #207.

MustangGB’s picture

Status: Needs review » Reviewed & tested by the community

#219 is just a re-roll of #207, so setting back to RTBC.

aaronbauman queued 219: 1464950-219.patch for re-testing.

Status: Reviewed & tested by the community » Needs work

The last submitted patch, 219: 1464950-219.patch, failed testing.

likewhoa’s picture

@MustangGB the re-roll was intentional, see comment #212 for details on why this was re-rolled. Now we need another re-roll to fix the patch failure

ivanatrix’s picture

Patch #207 applied successfully against latest 7.x-3.0-alpha1+16-dev. Pretty much solved my problem. Still don't understand why re-roll is needed.

zestagio’s picture

Status: Needs work » Needs review
FileSize
23.22 KB

Patch #207 no ok for me. Effects "Fade in/Fade out" and "Slide down/Slide up" not working for field collections.

zestagio’s picture

zestagio’s picture

stefan.r’s picture

please can you post an interdiff with 219 as well, for reference?

zestagio’s picture

Main differents are:

@@ -554,7 +555,7 @@ function conditional_fields_form_after_build($form, &$form_state) {
         // Build effect settings for effects with options.
         // TODO: add dependee key to allow different effects on the same selector.
         if ($options['effect'] && $options['effect'] != 'show') {
-          $selector = conditional_fields_field_selector(drupal_array_get_nested_value($form, array($dependent_location[0])));
+          $selector = conditional_fields_field_selector(drupal_array_get_nested_value($form, $dependent_location));

this changes are required, because on ajax updation of the field collection (add or remove field item), we must update settings, because html IDs updating on each ajax request:

@@ -629,14 +638,8 @@ function conditional_fields_form_after_build($form, &$form_state) {
 
   // Add effect settings to the form.
   if ($effects) {
-    $form['#attached']['js'][] = array(
-      'data' => array(
-        'conditionalFields' => array(
-          'effects' => $effects,
-        ),
-      ),
-      'type' => 'setting',
-    );
+    $settings = array('conditionalFields' => array('effects' => $effects));
+    drupal_add_js($settings, 'setting');
funkeyrandy’s picture

i cant seem to apply #229 to latest dev...any help?

patch unexpectedly ends in middle of line
patch: **** malformed patch at line 472:

zestagio’s picture

Ok for me

gjones’s picture

Hunk #4 FAILED at 386

gjones queued 219: 1464950-219.patch for re-testing.

The last submitted patch, 219: 1464950-219.patch, failed testing.

madelyncruz’s picture

#195 patch works. Thank you.

bpadaria’s picture

#195 worked for me as well.

Thanks.

Solidus_BR’s picture

#195 is working very well. It solved my problem! Thanks a lot!

kenorb’s picture

Status: Needs review » Reviewed & tested by the community
njbarrett’s picture

#195 doesn't seem to apply on the latest dev anymore. I used #229 and that is working.

tengoku’s picture

i downloaded latest dev version but #229 patch is not working... it will trigger php error for bad } location

UPDATE: Tried today and worked... i think i did a bad patch before

TravisJohnston’s picture

Thanks a lot! I am using Conditional Fields with Commerce Registration and there are often times more than one registration form on a page, and only the first registration form was adhering to the conditional rules while all additional forms just showed all fields without hiding them by default. #195 worked for me with the latest dev.

joelstein’s picture

#195 worked for me with latest DEV. Also needed this for Commerce Registration. Thanks!

letuptit’s picture

#195 worked for me. very good. Thank you very much.

MmMnRr’s picture

#195 worked for me.

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

I had to use the older Conditional Fields 7.x-3.0-alpha1 version instead of the latest 7.x-3.0-alpha2 version.
Some errors appear when applying the patch from #195 to the latest version:

patching file conditional_fields.module
Hunk #5 FAILED at 389.
Hunk #9 succeeded at 541 (offset 1 line).
Hunk #10 succeeded at 632 (offset 1 line).
Hunk #11 succeeded at 1004 (offset 4 lines).
Hunk #12 succeeded at 1993 (offset 4 lines).
1 out of 12 hunks FAILED -- saving rejects to file conditional_fields.module.rej
tengoku’s picture

Status: Reviewed & tested by the community » Needs work

thanks @MmMnRr, using drush.make the #195 patch and Conditional Fields 7.x-3.0-alpha1 applied succesfully with no errors and is working.

latest version of conditional fields 3.0-alpha2 still has the problem, and #195 and #229 patch doesn't work.

hanoii’s picture

Status: Needs work » Reviewed & tested by the community

For me, #229 applies fine on both dev and alpha2 and in both I see it does solve the problem. For the ones that don't, maybe give a bit of an example of their use case. Might be nice to create a feature module with the CTs and FCs involved that could help narrow this down. But it is a much needed fix.

ronaldmulero’s picture

I also confirm that patch #229 works fine on both dev and alpha2 and solves this problem. Thank you zestagio!

tengoku’s picture

i tried the patch #229 again on alpha2 and now works (my bad sorry).. thanks!!!... is there a reason for this not to be merged?

francoisleralle’s picture

I confirm patch #229 works fine on alpha2

Arne Slabbinck’s picture

Confirming patch #229 works on Conditional fields 7.x-3.0-alpha2 !

(using Field Collection 7.x-1.0-beta8)

Thx!

parasolx’s picture

Confirming that patch #229 also works for me using Conditional fields 3.0-alpha2. Should incorporate into latest version.

acrosman’s picture

joshf’s picture

Status: Reviewed & tested by the community » Needs work

This patch causes a regression for me.

I have a node type "Event" with two fields, "Featured" and "Speakers."

"Featured" is a boolean.

"Speakers" is a field collection which depends on "Featured" being checked. It has several fields such as "Bio" and also a boolean for "External". Depending on the value of the "External" checkbox, different fields on the field collection item are shown or hidden.

This last functionality (changing the field collection fields available when based on the "External" value) works, now, thanks to this patch. However, with the patch applied, changes to the field collection items no longer save properly. No error appears; the changes just don't show up. Without the patch, everything saves properly. Also, when I remove the dependency between "Speakers" and "Featured", everything saves properly.

joshf’s picture

Attached a reduced test case demonstrating the issue reported in #259.

I found that it doesn't seem to matter if your field collection items have dependencies. If the field collection field itself is dependent on another field, the field collection doesn't save properly.

Steps to reproduce:
1. Enable the attached module
2. Browse to /node/add/event
3. Fill in the Title field
4. Check "Featured"
- "Speakers" field should appear
5. Fill in a Bio for one of the "Speakers" field collection items
6. Click save
7. Return to the edit screen for the new node
- Observe the Bio information is not saved

Thanks for everyone's hard work on this.

joshf’s picture

The attached patch applies cleanly to the latest dev and does not exhibit the issue I described above.

I didn't really do anything other than reroll it, so my issues may have been a result of trying to patch alpha2.

anou’s picture

Patch from joshf (#261) works for me. Thanks.

Unitoch’s picture

Status: Needs review » Reviewed & tested by the community

I can confirm that the patch from #261 also applies cleanly for me to alpha2, and also eliminates this issue. Marking RTBC.

sassafrass’s picture

I can confirm that the patch from #261 applies cleanly for me to 7.x-3.x-dev, and eliminates this issue. Thank-you!

LiamPower’s picture

I can also confirm that the patch from #261 fixes the issue when applied to 7.x-3.x-dev

nwoodland’s picture

Patch from #261 fixed the issue for me on the latest dev version as well

ovi.indrei’s picture

I confirm that patch from #261 works in 7.x-3.0-alpha2

scotwith1t’s picture

+1 for this patch against dev. Thanks!! Let's get this thing committed.

lasensio’s picture

I confirm that patch from #261 works in 7.x-3.0-alpha2 for the exact same issue with Paragraphs

akishankar’s picture

I confirm that patch from #261 works with:
conditional fields module v-7.x-3.0-alpha2
field collections module v-7.x-1.0-beta11.

This patch can be committed.

badcrocodile’s picture

Patch #261 worked for me with Paragraphs 7.x-1.0-rc4 & Conditional Fields7.x-3.0-alpha2!

paulwdru’s picture

#261 patch works for 7.x-3.0-alpha2

Multivalue Multified was also solved. Great & thanks

peterpoe’s picture

Status: Reviewed & tested by the community » Needs review
FileSize
24.76 KB

Please test this new patch.

Changes from #261:
- Avoid changing the signature of API function conditional_fields_attach_dependency()
- Simplified creation of field parents key
- Code styling and comments

Status: Needs review » Needs work
peterpoe’s picture

Oops.

peterpoe’s picture

Note: when committing, also add credit to liquidcms, ocastle from #1648128: field collections within other field collections do not function when set as dependents

xaffimarc’s picture

I can confirm #275 works for me on the latest dev version (7.x-3.x-dev | 2016-Mar-29)

Also, my use case is for commerce registration when using conditional fields on multiple registrations at the same time

kenorb’s picture

stefan.r’s picture

FileSize
22.93 KB

Interdiff between 261 and 275

alanburke’s picture

Status: Needs review » Needs work

No longer applies

b.anas’s picture

#275 works great, thanks guys !

pipep’s picture

#275 +1

Thanks !

hanoii’s picture

@peterpoe indeed the patch doesn't apply anymore. I just attempted to re-reroll but you refactor one bit of code that probably needs modifying, specially around conditional_fields_evaluate_dependencies and a new function so as you seem to be on top of this, probably best if you tacked it yourself.

aburrows’s picture

Same issue as @hanoii, i'm currently working on this issue for a project so will hope to create a patch.

UnsettlingTrend’s picture

275 seemed to work fine for me! (crossing fingers that it stays that way.)

Huelfe’s picture

#275 works for me, thank you! :)

Shashwat Purav’s picture

Confirmed #275 worked on Drupal 7.43 and "Conditional Fields" module version 7.x-3.0-alpha2.

paulwdru’s picture

Hi,

Since the patch works & tested, why not committed ? Otherwise there'll be infinite re-roll & re-roll & re-roll...

Thanks

alimbert’s picture

Any Update on patch #275 being applied to a release?

paulwdru’s picture

Hi,

Currently, too many patches are created for different bugs and can't be applied 1 after another, for eg after applying patch #275 here, I FAILED to apply the patch #139 in #1561272: Conditionally required fields are not required.

Hence, please commit the patches once tested to be working instead of dragging the issue indefinitely resulting in conflicts with other patches for other bugs.

Thanks

sketman’s picture

#275 works for me, let's commit it please..

stevendeleus’s picture

The problem persists if the dependent fields are images with the media widget (Media module). It can be solved by adding one extra check for the entity bundle:

<?php
  if (isset($field['#entity_type'], $field['#bundle'])) {
    $entity_type = $field['#entity_type'];
    $bundle = $field['#bundle'];
  }
  elseif (isset($field[0]['#entity_type'], $field[0]['#bundle'])) {
    $entity_type = $field[0]['#entity_type'];
    $bundle = $field[0]['#bundle'];
  }
  elseif (isset($field[0]['#entity_type']) && $bundle = _conditional_fields_field_parent_bundle($field)) {
    $entity_type = $field[0]['#entity_type'];
  }
  elseif (isset($form['#entity_type'], $form['#bundle'])) {
    $entity_type = $form['#entity_type'];
    $bundle = $form['#bundle'];
  }
  else {
    return $element;
  }

?>
calebyoder’s picture

#275 seems to be working for me with the little I tested it (in my situation). Thanks!

-Caleb

akishankar’s picture

#275 +1

DarkteK’s picture

#275 ++1 Worked like a charm !

Edit: Patched applied on version "7.x-3.0-alpha2"

fire-wolf’s picture

#275 works great! Thanks!

morybel’s picture

Hi,
I have tried 3 times #275 and I always get fatal error. This is the longest patch I have come across so far so I'm guessing I'm doing some copy-paste error somewhere. Could someone upload a copy of the file conditional_fields.module so I can test. I have 7.x-3.0-alpha2.

Thanks.

knalstaaf’s picture

#275: "Can't apply 4 of 57 hunks" when applying it on 7.x-3.x-dev (2016-Mar-30) - see #283.

MahtabAlam’s picture

#275 works for me. :) Thanks

DarkteK’s picture

Hi,
I have tried 3 times #275 and I always get fatal error. This is the longest patch I have come across so far so I'm guessing I'm doing some copy-paste error somewhere. Could someone upload a copy of the file conditional_fields.module so I can test. I have 7.x-3.0-alpha2.

Thanks.

@morybel What O.S are you using, linux? Windows?

capogeannis’s picture

Many thanks. #275 working great for me.

usdv’s picture

Hey guys,

I use Conditional Fields module with Multifield module https://www.drupal.org/project/multifield and I had the same problem. So the good news is that patch #275 works well with this module as well. Thanks a lot!

kespinosa05@gmail.com’s picture

There is patch integrating some patch
conditional_fields-fixed_multiple_field_collection_fields-1464950-276.patch and conditional_fields-conditionally_required-1561272-152.patch into 7.x-3.x branch of yesterday both works for me.

kyoder’s picture

Patch #275 no longer applies cleanly against the latest dev branch.

aaronglamb’s picture

#275 succeeded on 7.x-3.0-alpha2 with PHP 7.0.8.

Excellent work - thank you!

djdevin’s picture

#275 causes a fatal against 7.x-3.x even re-rolled, so something else must have changed.

I tried #303 which does show/hide field collections properly, however, required field collections are still required even when not triggered.

karthid’s picture

#275 works great. Thanks

jomarocas’s picture

For me the patch working good, why users tell that no working, maybe conflict with other module, update the issue

MustangGB’s picture

Title: Support for multiple "Field Collection" fields. » Support for multiple "Field collection" and "Multifield" fields

Patch also adds support for multiple Multifield fields.

b_sharpe’s picture

#275 applies to 7.x-3.0-alpha2 cleanly, but does not account for field translation.

Here is the updated version for field translation. Again, this is against 7.x-3.0-alpha2 as Dev appears to need a full re-roll of this patch at this point (hence why leaving in 'needs work')

jyraya’s picture

@MustangGB, it is a good news that the patch adds support for multiple Multifield fields.

Nevertheless, IMHO, we should not change the issue title to include this type of fields by cause we enlarge the issue scope and then, we risk that problems related to "Multifield fields" pop up and block the ticket closure for months while a lot of us are waiting a final fix since almost 4 years.

If there are problems with "Multifield fields", that should then is treated in a different ticket.

kopeboy’s picture

#310 works with 7.x-3.0-alpha2 (latest stable release)!
Thanks!

ocastle’s picture

#310 also works for me on 7.x-3.0-alpha2 with Field Collections.
Cheers.

shuva.15’s picture

#310 works perfectly with 7.x-3.0-alpha2 version. Thanks..

msantos202’s picture

#310 works perfectly with 7.x-3.0-alpha2 version. Thanks..

slipstreamer’s picture

#310 works perfectly with 7.x-3.0-alpha2 version. Many Thanks to those who have worked on this.. Any chance this being pushed to dev?

donaldwbabcock’s picture

Also can confirm #310 applies against 7.x-3.0-alpha2 version and resolves my issues with Conditional Fields and Paragraphs 7.x-1.0-rc4. In my case at render the Conditional Field dependencies were respected, but in the editor interface only the first paragraph of an multi-paragraphs field on any node was being affected by the dependencies.

Can we get this refactored against current dev and then committed, given our utter dependency on paragraphs (and nested entities generally) this now seems like long past due.

pauljb’s picture

#310 works for me too. Thank you.

cgoffin’s picture

#310 works for me too. Thank you for the contribution.

donaldwbabcock’s picture

It's been about a month of messing around with this and I've found that #310 + 7.x-3.0-alpha2 + Paragraphs 7.x-1.0-rc5 (rc4 until yesterday) works "for most use cases".

One where it does not is paragraph fields inside paragraphs in editor mode.

If I have a dropdown and a paragraph entity field on a node, it works as expected, the paragraphs field is hidden for both editor and display (I haven't tested it but I think this was true without #310).

If I have a dropdown and a paragraph field inside a paragraph, and the drop down controls whether the "child" paragraph field shows, it does not "hide/show" the paragraph in the editor, but is correctly hidden/shown in the display.

I have been able to trace it as far as being able to see that a state trigger is not being attached to the dropdown in the editors interface for the nested paragraph.

Perhaps someone more familiar with CF and this patch thread could easily spot why nested dependent paragraphs are not getting a proper state on the editor side.
-----------------------------------------
EDIT: to clarify, I have traced that an event listener is not being registered for the dropdown and reflected in DOM.

siva_drupal’s picture

#310 work for me too. Thanks a lot for the contribution.

Kris77’s picture

It seems to not work with FieldGroup Multiple module...

cgoffin’s picture

The patch from #310 worked for me, but sometimes I get php notices. I added an extra check to the patch to fix those notices.

Nishruu’s picture

@cgoffin, your patch should contain only relative paths (no sites/all/modules/...). (see https://www.drupal.org/node/367392 ).

smurfxx’s picture

I'm a bit confused: starting form 7.x-3.0-alpha2+10-dev which patches do I have to apply?

Is there a single patch to apply to 7.x-3.0-alpha2+10-dev? Or can someone post a conditional_fields.module already patched?

Thanks!

EDIT: Sorry I see that patches are applied to latest stable release, sorry!

hondaman900’s picture

Patch at #275 worked fine for me on 7.x-3.0-alpha2. I used Netbeans to apply the patch.

Thank you!

SocialNicheGuru’s picture

is there a patch that will apply to the latest dev?

drclaw’s picture

Status: Needs work » Needs review
FileSize
23.47 KB
1.92 KB

Here's a version of the patch in #310 that applies to the 7.x-3.x-dev branch. I didn't use the one from #323 because it doesn't apply, and there was no interdiff to actually see what the differences were from the earlier one.

On the topic of interdiffs, it's hard to produce one that's meaningful when re-rolling a patch for a different branch. Instead I've just diff'd the patches using OSXs command line diff tool. It basically just highlights the two blocks from the original patch that had problems applying.

I tested this quickly with the paragraphs module (which has the same issues as field collection) and it appears to work. Hopefully someone can give it a whirl with field collection and report back!

Thanks!

Status: Needs review » Needs work

The last submitted patch, 328: conditional_fields-1464950-328.patch, failed testing. View results
- codesniffer_fixes.patch Interdiff of automated coding standards fixes only.

SocialNicheGuru’s picture

#328 This causes field_collections to longer be affected by conditional_fields. It is always visible

no it was not this patch. it was another.

Brandonian’s picture

Status: Needs work » Needs review
FileSize
23.95 KB

While testing patch #328 in our codebase, I ran into an issue where conditional_fields_field_form_get_values() would fail, because of line ~1040

$field_parents = $form['#conditional_fields'][$field_name]['parents'];

In our case, $form['#conditional_fields'][$fieldname] didn't exist. This would cause issues with, in our case, adding paragraph bundles to an unlimited paragraph bundle field. Attempting to add a bundle would cause a difficult-to-debug 500 AJAX error.

Given the description of the function, I added an empty check to the top of the function to return early an empty array if $form['#conditional_fields'] is empty. I'm unsure of exactly how to replicate the issue in a clean install, but I'm open to suggestions on how to better address if there's a better way, and/or if anyone has more insight in how to replicate this issue.

Status: Needs review » Needs work

The last submitted patch, 331: conditional_fields_multifield-1464950-331.patch, failed testing. View results
- codesniffer_fixes.patch Interdiff of automated coding standards fixes only.

BR0kEN’s picture

More than one dependee for the dependent will cause values to clean... (so, the patch is not fully working still)

Gosh, how shitty complex this project is.

phpsubbarao’s picture

#310 working perfectly, thanks a lot

jojonaloha’s picture

Attached is a patch that also fixes a PHP Notice and Warning that I was getting after applying the patch in #333 against 7.x-3.x-dev.

Notice: Undefined variable: state in conditional_fields_form_after_build()
Warning: Invalid argument supplied for foreach() in conditional_fields_form_after_build()

Also attaching two interdiffs, the first includes whitespace changes, the second ignores whitespace changes (a lot easier to read).

capellic’s picture

Just applied the patch in #335. Thanks @jojonaloha & @BR0kEN & everyone else.

kenorb’s picture

Status: Needs work » Reviewed & tested by the community

The last submitted patch, 310: conditional_fields-1464950-310.patch, failed testing. View results

The last submitted patch, 323: conditional_fields-1464950-323.patch, failed testing. View results

gmarchev’s picture

It seems multiple dependees for a single dependent have stopped working sometime after #310. Currently the last dependee state overwrites the previous one.

gmarchev’s picture

Status: Reviewed & tested by the community » Needs review
anrikun’s picture

Status: Needs review » Needs work

When a required dependent is hidden, "FIELDNAME field is required in the COLLECTION collection." still shows up for the 2nd or more items.

Isostar’s picture

I can confirm the issue mentioned by anrikun.

If you have inside a fc:
- radio field with optionA and optionB (required)
- optionA options list (required and only visible if optionA is checked)
- optionB options list (required and only visible if optionB is checked)

You will get the error 'OptionB options is required in the COLLECTION collection' when optionA is checked and optionB options list is hidden.
from the 2nd fc on.

niallmurphy-ie’s picture

7.x-3.0-alpha2+10-dev and #341 applied cleanly and seems to work as intended. Thanks.

scotwith1t’s picture

Thanks, but only partial success with the patch in #341. Specifics (without the latest dev w/patch):
- We are dealing with Scald, which allows you to create multiple entities at once via plupload. Once you've uploaded the images, you can then fill out the form for each individual scald entity ("atom") on the subsequent page.
- The fields in our implementation are a checkbox which hides 2 other fields when checked. Works fine on the first form, doesn't work at all with subsequent forms on the page.

With the latest dev and #341 patch, when the checkbox is checked in subsequent fields, only the 2nd field to be hidden is actually hidden. So close! Thought it might be because this often happens in a ctools modal, but I have the same problem when the form is filled out in a non-modal context.

vramiguez’s picture

I tried applying #341 patch on the 7.x-3.0-alpha2 version but keep getting

3 out of 12 hunks FAILED

(#8, #10 and #11)

Any idea why?

@niallmurphy-ie could you share the file you have to compare what is missing to get applied?

Thanks and help much appreciated.

niallmurphy-ie’s picture

vramiguez, this is my conditional_fields.module file: https://pastebin.com/UVP1Kx7T

vramiguez’s picture

Thanks a lot niallmurphy-ie!! It worked. Much appreciated.

kebne’s picture

7.x-3.0-alpha2+10-dev and #341 applied cleanly and seems to work as intended here too.

scotwith1t’s picture

Status: Needs work » Reviewed & tested by the community

Despite it not working for the use case I described in #346, I CAN confirm this does fix issues with field collections, so I think it should be committed at this point given the other confirmations above. I can open a new ticket for the Scald issue and perhaps figure out what's up with that particular situation.

anrikun’s picture

Status: Reviewed & tested by the community » Needs work

@scotself You skipped issue at #343 confirmed at #344.

scotwith1t’s picture

Indeed. Sorry about that!

Rasti’s picture

I copied ( #348 niallmurphy-ie ) code and pasted in my conditional_fields.module file , its works beautifully,

Thank you

emad.samirzaki’s picture

Which module version did you use before you replace your .module file with this one?

Rasti’s picture

I applied it to 7.x-3.0-alpha2 released 29 September 2015

SkyBuzz’s picture

I have applied #341 on dev release. Everything works perfectly except the field validation. It bypasses field validations.

calefilm’s picture

I applied #341 and it works cleanly. In my case, i have no problem with my dependency when validating a field.

validation = Specific value(s) for field_1
dependency = "field_2 is disabled when field_1 has value "0".

Chris Matthews’s picture

BramDriesen’s picture

I created a patch for #348 (pastebin file) against the current release (alpha 2).

Will probably fail to apply against dev.

calefilm’s picture

Thank you BramDriesen,

I tried patching in alpha version but received

patch unexpectedly ends in middle of line

I found reference for resolving this here: https://www.drupal.org/node/60116

This error seems to occur when the patch file ends on a line that includes nothing but whitespace characters. Patch files should always end with a Unix return character. If you encounter this error, check to see that the last line of your patch does not contain whitespace characters.

Can you resolve this issue and repost the patch?

Thank you!

BramDriesen’s picture

Indeed there was an issue with that patch. No idea how that happened.

Attached new patch. Only difference is the trailing "+"

calefilm’s picture

Is it just me? I'm still getting this:

patch unexpectedly ends in middle of line
patch: **** malformed patch at line 693:

Thank you for any assistance

calefilm’s picture

@BramDriesen,

Thank you for the patch. I added an extra line at the end. Line 695 is now a blank line and, as a result, the patch is applied cleanly without the above messages. Not sure if that is correct on my part but your patch work as intended now.

rajveergangwar’s picture

Pancho’s picture

Faced with the paralyzing situation that patch #341 had some remaining issues, while a seemingly all-new approach #348/#360/#362 failed to apply against latest dev, I carried out a three-way-merge of #348, only to find out that it has only few lines changed against the last working patch #341. These might be critical, but it's not like we're going a totally different path.

So here's my (hopefully properly applying) reroll of #348, together with an interdiff against #341. May the intense, good work continue!

Status: Needs review » Needs work
Pancho’s picture

The three-way-merge somehow duplicated conditional_fields_library(), so I manually fixed that one.
Now these three changed lines should be all what's different between #341 and #348, see the interdiff.
If not or if it doesn't turn out to work better than #341, we should probably return to the latter, and go on from there.

Status: Needs review » Needs work
Pancho’s picture

#368 fails, too. So I think we should return to patch #341 which mostly worked fine, still does properly apply and tested green (tested today).

I'm wondering if it might be the best way forward to just get #341 committed and continue from there on with a few followups to tackle the remaining aspects. This issue here has become all too long and the patch has become all too complex to still be productive.

Setting back to Needs review per #341.

BramDriesen’s picture

Status: Needs review » Needs work

As to the follow up comments on #341, there are issues with the patch.

sassafrass’s picture

I applied patch #341 to the latest version of dev an this works for me. Thank-you!!

AlfTheCat’s picture

Also applied #341 and works great against latest dev. Thanks!

Thangaraj Moorthi’s picture

#348 works fine. Tq so much

guitarodactyl’s picture

Copy/pasted #348 over the top of conditional_fields.module file in the 7.x-3.0-alpha2 release, worked for me

dunot’s picture

#229 applies to 7.x-3.0-alpha2, not to 7.x-3.0-alpha2+10-dev.
#341 applies to 7.x-3.x-dev (7.x-3.0-alpha2+10-dev), not to 7.x-3.0-alpha2.
I've tried #348 (#360), but all these patches result no success
for file upload field dependant on text field
(video_embed_field in collection with deltas).

Selectors like [id*='edit-field-gallery-und'] doesn't work in "Custom jQuery selector for dependee".
Selectors like .video_embed_url hide all file upload dependant fields
if first instance dependee field has value.

James Feng’s picture

#229 suits me very well. My version is 7. X-3.0-alpha 2

ergonlogic’s picture

FYI, we're working on a similar feature for the D8 version in #1161314: Add basic Field Group support for ANDing conditions.

pinueve’s picture

#341 against version 7.x-3.0-alpha2 works perfect

delacosta456’s picture

hi i conform that #341 works on dev..
But i am a little confused on my own side about this issue Cross entity (Inline Entity form and... that ask to first apply #67(here) before using the patch on that issue .. which logically means to me that all modifications of patches here after #67 (even #341) will not be included ...

After applying successfully #341 here i could not apply the patch here (Cross entity ...Inline Entity form and...) anymore ..

Can somebody help understand and know what to do ?

Thanks

vibrasphere’s picture

The #341 works for --dev only, thank you.

The bug is 8 years old from 2012. Why is this module still in alpha and not stable with 800k downloads and 70k active installs for both D7 and D8, I'm sorry but what does it take to go stable?

BramDriesen’s picture

@vibrasphere Is there a need to get this stable? D7 is closing in on it's EOL :-)

vibrasphere’s picture

Okay, D8 stable when?

slv_’s picture

Reuploading the patch from #362, with the empty line at the end.

juampynr’s picture

Here is an updated version which applies to 7.x-3.0-alpha2 and fixes the following warning:

Warning: array_reverse() expects parameter 1 to be array, null given in _conditional_fields_field_parent_bundle() (line 2061 of conditional_fields.module)
dqd’s picture

Priority: Major » Normal
Status: Needs work » Closed (outdated)

#382 / #383 need to be addressed. Apart from that it is not ensured that this issue still persist in its whole scope today.

Thanks for the report and all the efforts in here. But due to upcoming EOL of Drupal 7, I will close this issue on the way by cleaning up the issue queue.

Feel free to re-open as "Needs review" if you found a solution or have a patch to be reported to help others on this outdated version.

If you think this issue or missing feature should be addressed in a newer Drupal core 8 and above compatible version of this project, then please file a new issue to the latest dev. Thanks for understanding.