Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
I've not tried to include conditional fields in a feature before, so forgive me if I have this wrong.
I included the conditional field component for a content type and it appeared to be created and then imported into another site correctly (it shows as a component in the feature in the other site).
However, when I check the 'manage dependencies' tab of the content type in the site the feature was imported into, I see no dependencies.
Am I doing something wrong or is this a bug?
Comment | File | Size | Author |
---|---|---|---|
#38 | conditional_fields-1275284-38.patch | 5.11 KB | leewillis77 |
#35 | conditional_fields-1275284-35.patch | 5.06 KB | leewillis77 |
#30 | Screen shot 2012-02-06 at 8.21.56 AM.png | 89.32 KB | alberto56 |
#27 | conditional_fields-1275284-26.patch | 4.44 KB | rlmumford |
#26 | conditional_fields-1275284-23.patch | 4.58 KB | rlmumford |
Comments
Comment #1
Shadlington CreditAttribution: Shadlington commentedThe conditional_fields.inc file in the feature contains only the following function:
Comment #2
Shadlington CreditAttribution: Shadlington commentedI thought maybe I was doing this wrong but now I'm pretty certain this is a bug.
No matter what I do, the generated feature doesn't contain anything other than the code in my previous post.
Comment #3
dalguete CreditAttribution: dalguete commentedHi guys
I made two patches for this bug. Hopefully this will help you too. Feedback appreciated.
Comment #4
Frippuz CreditAttribution: Frippuz commentedIt seems like GIT is having problems reading the patches by dalguete. I remade them using git diff.
All creds to dalguete for the coding.
Comment #5
willvincent CreditAttribution: willvincent commentedHere's an older p0 format of the patch in #4 that can be applied with a drush make.
Comment #6
willvincent CreditAttribution: willvincent commentedForgot to mention (though it was probably implied) the patch from #4 works for me.
Comment #7
Shadlington CreditAttribution: Shadlington commentedPatch #4 works for me too!
Comment #8
willvincent CreditAttribution: willvincent commentedMarking RTBC
Comment #9
JordanMagnuson CreditAttribution: JordanMagnuson commentedI'm new to this whole patching business, and I'm having trouble getting these to apply... is there something I'm doing wrong?
I'm getting "trailing whitespace" messages, then "fatal: corrupt patch at line 43."
I'm sure I'm missing something obvious.
Comment #10
Shadlington CreditAttribution: Shadlington commentedProbably best to just download the patch file rather than using C&P
Comment #11
mrfelton CreditAttribution: mrfelton commentedPatch in ¢ works for me too. Thanks.
Comment #12
mrfelton CreditAttribution: mrfelton commentedPatch in #4 works for me too. Thanks.
Comment #13
acrollet CreditAttribution: acrollet commentedworks for me as well, export and revert - any chance of getting this into a release?
thanks much!
Comment #14
geek-merlindaring to mark critical. hey, it's features suppport!
Comment #15
3rdLOF CreditAttribution: 3rdLOF commentedNot for me:
In one install the error does not appear, on the other, both create and recreate generate this:
Warning: Invalid argument supplied for foreach() in conditional_fields_features_export_options() (line 14 of /Users/quiky/Sites/sepul/sites/all/modules/contrib/conditional_fields/includes/conditional_fields.features.inc).
Comment #16
emattias CreditAttribution: emattias commentedThe changes in #3 causes the conditional_fields_features_rebuild to not work since it depends on the old structure of the $dependancies before #3 which makes reverting of conditional fields settings not work, since it's not able to delete settings before inserting the settings from the features export.
Heres a patch that includes dalguete changes from #3 and also makes conditional_fields_features_rebuild work when the patches in #3 are applied.
I haven't deepdived into this new features implementation. All I did was make the rebuild work with the new structure introduced in #3. From my testing this seams to fix reverting of conditional fields settings.
Comment #17
emattias CreditAttribution: emattias commentedComment #18
BarisW CreditAttribution: BarisW commentedGreat work! Patch works nicely.
I've tested:
Please commit this patch to the module.
Comment #19
rogical CreditAttribution: rogical commentedthis module is very useful, but seems update with a bit late.
I suggest someone can take a role of co-maintainer.
Comment #20
mariano.barcia CreditAttribution: mariano.barcia commented[edit] well I guess not, I'll try how it works with features in D6
Hi! Would this last patch in #16 work in v6.x-2.0?
Thanks
Comment #21
BarisW CreditAttribution: BarisW commentedNo Mariano, this is a patch for D7.
Comment #22
tim.plunkettThis module followed the documentation properly, unfortunately the docs were incorrect: #1402262: features.api.php mentions 'features_source' key, but the actual key in use is 'feature_source'
Updated the patch.
Comment #23
tim.plunkettSwitched to using features_var_export, it pretty-prints the arrays better.
Comment #24
ShaneOnABike CreditAttribution: ShaneOnABike commentedI can confirm that this patch works although when I tried to apply it it complained and I had to modify teh file. Could you regenerate your patch to be just above the conditional_fields directory rather then where you did. It makes it harder to apply for those non-GIT geeks. :P
Comment #25
tim.plunkett@ShaneOnABike try
patch -p1 < conditional_fields-1275284-23.patch
Comment #26
rlmumfordHere's the patch in the right directory. Can confirm that it does the trick. Thanks tim.plunkett!
Comment #27
rlmumfordWhoops! Uploaded the wrong one..
Comment #28
BarisW CreditAttribution: BarisW commentedOne minor addition in
conditional_fields_features_export_options()
I changed
$dependencies = conditional_fields_load_dependencies();
into
Because I got a PHP notice that '$dependencies was not an array' when I want to create a feature and I didn't create any conditional fields yet.
Comment #29
ShaneOnABike CreditAttribution: ShaneOnABike commented@tim.plunkett That worked great :)
Comment #30
alberto56 CreditAttribution: alberto56 commentedHi, thanks for the patch.
I am getting the following error when running automated tests (see also enclosed image):
Undefined index ... in conditional_fields.features.inc
To reproduce, simply export any conditional fields into a feature, and add an associated .test file and run it.
Cheers,
Albert.
Comment #31
TravisCarden CreditAttribution: TravisCarden commentedThe patch in #27 worked for me, with the caveat that when I migrated changes I was unable to revert the conditional fields components from Drush—I had to do it from the UI, for some reason.
Comment #32
leewillis77 CreditAttribution: leewillis77 commentedThe patch in #27 doesn't work for me. I'm exporting a feature, and then activating the feature as part of an install profile. During site installation I get a number of warnings of the form:
Notice: Undefined index: field_resource_type in conditional_fields_features_rebuild() (line 105 of /home/webserver/testinstall3/sites/all/modules/conditional_fields/includes/conditional_fields.features.inc)
and no conditional fields are on the system when I view the content type and hit Manage Dependencies. Could it be that its trying to set up the conditional fields before creating the fields?
Comment #33
jantoine CreditAttribution: jantoine commentedThe error reported in #32 is happening because Features is trying to create the conditional fields before the fields have been created. If features provides a way to control the order of execution, conditional fields should not be run until after fields have run. A work around is simply to revert the feature once installed. I have verified this using the patch in #27.
Comment #34
tim.plunkettHm, conditional_fields could implement
hook_module_implements_alter()
to ensure it runs after field.module.Comment #35
leewillis77 CreditAttribution: leewillis77 commentedFollowing Tim's suggestion, the updated attached patch includes #27, and in addition implements hook_module_implements_alter() to force conditional fields' implementation of hook_features_api to run last.
This works for me as part of an install profile without requiring the feature to be reverted post install to take effect.
Comment #36
kalis1Just a note to say that the patch in #35 works well. Thank you !
Comment #37
tim.plunkettNo spaces after parentheses. Also, this should follow the example given in http://api.drupal.org/api/drupal/modules%21system%21system.api.php/funct... and use
$group
, not just assign ''.Comment #38
leewillis77 CreditAttribution: leewillis77 commentedFair comments. Updated patch attached.
Comment #39
tim.plunkettAwesome!
Comment #40
drupalycious CreditAttribution: drupalycious commentedThe patch doesn't work for me,
it might be a different issue.
When I want to create a feature, I have the following error message:
Notice: Undefined index: in conditional_fields_features_export_options() (line 18 of my-drupal-site-directory/sites/all/modules/conditional_fields/includes/conditional_fields.features.inc).
I applied the patch in #38 and during the patch I got:
and then in the website, the error message in the create features section became:
Warning: Invalid argument supplied for foreach() in conditional_fields_features_export_options() (line 14 of my-drupal-site-directory/sites/all/modules/conditional_fields/includes/conditional_fields.features.inc)
Comment #41
tim.plunkett#40 did you apply that to the latest dev? It applied cleanly for me.
Comment #42
drupalycious CreditAttribution: drupalycious commentedYes, I applied it to the latest dev.
Comment #43
tim.plunkettgit clone --branch 7.x-3.x http://git.drupal.org/project/conditional_fields.git
cd conditional_fields
curl http://drupal.org/files/conditional_fields-1275284-38.patch | git apply
Comment #44
leewillis77 CreditAttribution: leewillis77 commented#40 - looks like the patch file you have is incomplete - can you re-download and try again?
"patch unexpectedly ends in middle of line"
Comment #45
jantoine CreditAttribution: jantoine commentedThe patch in #38 is good, please commit!
Comment #46
drupalycious CreditAttribution: drupalycious commented@tim.plunkett and @ leewillis77
you were right I didn't applied the patch correctly, I copied the patch and used -p0.
I am still learning...
The patch is good for me too.
Thank you
Comment #47
hlykos CreditAttribution: hlykos commentedPatch works great
Comment #48
peterpoe CreditAttribution: peterpoe commentedJust committed, thanks dalguete, emattias, tim.plunkett, leewillis77 + all testers.