I know this is very early, but I personally think this module is *really* awesome, and I expect it to get a lot of use once it gets out of sandbox. I've been using it and I haven't run into any problems at all. So I'm just going to suggest really early that you go ahead and add support for exportables using the Features module. Since fields are already supported, people who are using Features (like me) will inevitably just expect that these conditional states will come along for the ride. I tested, but they don't currently. :( sad for me.
Here's to hoping you have the time and can add it fairly easily. I don't know how difficult it would be, but it's currently beyond my skill level.
You can find the documentation for how to proceed here: http://drupalcode.org/project/features.git/blob/031e6d4d7318245859c590d8...
Once again: Awesome module!
Comments
Comment #1
peem83 commentedThank you for your suggestion I have been thinking on that feature also and I will try to start work on it asap.
Comment #2
jtbayly commentedWow. That's really awesome. I'm looking forward to it!
-Joseph
Comment #3
shiraz dindarsubscribe
Comment #4
tnanek commentedSubscribe. Great work so far.
Comment #5
adamgerthel commentedI second this. The module works great so far, but features support would be awesome
Comment #6
goldenboy commentedsubscribe
Comment #7
arrubiu commentedsubscribe
Comment #8
spidermanI've begun work on a patch for this, but have never implemented ctools/features exportable integration before, and have unfortunately been unable to make it work as desired. I've decided to post my patch as work in progress, in hopes someone else might be able to move it forward.
I've read all the documentation re: ctools export/features integration that I can find, and it all seems straightforward. Initially I tried to implement just the plain ctools export steps (as described here), excluding the export UI bits (since I'm planning to just use Features to do the exporting for me). This seems to *almost* work- the conditional presets show up on the "create feature" screen as a component, and even seem to export into a feature module properly.
The issue I ran into was *importing* the presets again- they never re-appear in the db. It seems that by default, CTools assumes any non-overridden presets can just live in code, and your module must check both places any time it's loading them. I found this post which describes this situation quite well, but adding the hook_features_rebuild and hook_features_revert implementations as described there didn't help any.
All of this has me very confused since it *seems* like all the right pieces are in place. As such, my hope is that I'm missing some small detail which another set of eyes may help identify more quickly than me staring at in frustration.
Some details on the patch:
To test:
The patch should apply against the latest 7.x-1.x branch as of when I cloned it a few days ago- I notice there's one more small commit since then, which should not affect this.
You should have ctools, features, and devel modules installed and enabled. Create a couple of conditional states and then go to admin/structure/features and create a feature. Include your conditions in there, download and install the new feature module on your test site. Inspecting the code for that site should show the conditions properly exported into code. Run a drush fr --force on the feature, which should trigger the features_revert function to run (it apparently doesn't initially, which may be part of the problem). This triggers the dd() calls, and you should see output in /tmp/drupal_debug.txt.
I also added a dd() call to spit out the $export array just before returning it in the features module's implementation of hook_default_field_conditional_state, so this would also show up in the output. This revealed some strange behaviour: the function in the features module works as expected, and the dd() call spits out the array of conditions. However, the hook_features_revert function never gets them- when I dd() the $presets array after calling hook_default_field_conditional_state, it's empty! This is apparently the source of the trouble, since the features_revert mechanism never gets the presets to save them into the db. The other odd thing here is that the dd() output from the features module call shows up *after* the empty $presets array from the dd() call in the features_revert/rebuild hook, even though it should logically come before. I can't tell if this is just some oddity with output buffering or something, but it seems suspicious.
Anyone with more features.module/ctools skills care to take a crack at this? At very least, it'd be helpful to confirm the patch is NOT working for someone else- rule out the possibility of some quirk with my setup. At best, maybe it works properly for you, and then I just have to figure out what I'm doing wrong! Failing all that, maybe someone can see the detail(s) I've missed, and then all of us who love this module (and Features) can celebrate :)
Comment #9
kyleoliveira commentedAny progress so far?
Comment #10
spiderman@kyleoliveira: AFAIK no progress, although I still suspect there may have been something weird with my dev environment, and would love for someone else to test my patch to see if they can reproduce (or better yet: NOT) the broken-ness I was seeing. I'll try to followup with any updates to the patch as needed, as I'd love to see this module become Features-enabled :)
Comment #11
manuelBS commentedI will do the features integration and provide a patch here very soon
Comment #12
manuelBS commentedHere is the patch. I created it for the release, not for the dev version, so changed the version of this issue.
Comment #13
manuelBS commentedComment #14
ptmkenny commentedI applied the patch in #12 to the 1.0 version and cleared the cache. The patch appears to have been applied properly (I got the properly "xyz file was patched" messages) but when I go to the "Create feature" screen what am I looking for? I looked until the list of strongarm variables but I couldn't find anything...
EDIT: Nevermind, I found it-- it's under the header "Field Conditional State." I had to clear the caches twice, not once.
Comment #15
ptmkenny commentedI applied the patch; thanks for getting the ball rolling on this. I noticed two problems.
1. When I add some of the field conditionals to my feature, I can then create a new feature and add them again from the UI. Usually, once you add some items to a feature, you cannot add the same items to another feature through the UI. I don't know how this is enforced, but it is not being enforced here.
2. Currently, the way the names are provided on the features UI is very confusing. For example, I have two fields (where_to_study_explanation and where_to_study) that are both attached to two different content types.
In the UI, it shows this:
() - field_where_to_study_explanation by field_where_to_study
() - field_where_to_study_explanation by field_where_to_study
One of these is attached to the "Study" content type, while the other is attached to the "Teach" content type. But from the UI, it is impossible to tell which is which. Also, I don't know why the () are shown in front.
Comment #16
manuelBS commentedThanks for your hints. Your hint 1) is fixed with the new patch attached. But 2) I cannot reproduce, as in my installation it appears as
bundle (entity type) - DESCRIPTION THAT YOU ALSO HAVE
Looking forward your review.
Comment #17
manuelBS commentedAttached a new patch with some bugfixes applied against 1.1 and current dev version
Comment #18
chris burge commentedComment #19
hass commentedI'd love to see a import/export feature, too. States config can get quite large and complex with many fields.
Comment #20
Tobias Xy commentedUnfortunately the work on this issue here belongs to 1.x. Probably we need a new approach here for 2.x?
Comment #21
hass commentedComment #22
manuelBS commentedTo get a base for the 2.x work, I fixed some bugs in 1.x you can find the patch attached.
Comment #23
hass commented1.x is no longer maintained. Do not post patches for 1.x, please.
Comment #24
stefan.r commented@manualBS now that 1.x is unsupported did you have any plans of building in features support for 2.x?
Thanks!
Comment #25
manuelBS commentedSorry, I have no plans yet as the patch cannot be ported easily du to the changed structure. This year it will not be possible for me but I can couch somebody that want to implement it if needed.
Comment #26
joelhsmith commentedI'd buy a 6-pack... no... a 24-pack of beer for anyone who can make a patch to get 2.x version of this module into Features in the next two weeks!
Seriously, I'll find a way to get it to you ;-)
Comment #27
nixter commented@manualBS it is a new year! Any plans for features support for 2.x?
Comment #28
subhojit777Comment #30
subhojit777Seems like the tests are broken http://cgit.drupalcode.org/field_conditional_state/tree/field_conditiona..., and this should be handled in a separate issue. Changing it back to needs review.
Comment #31
pratip.ghosh commentedDefinitely need patch for 2.x
Comment #32
subhojit777Patch in #30 exports the field conditional states into code. But the import functionality is not working. It would be great if anyone look into this. Most probably the code for import is not written.
Comment #33
shelaneThere is a similar module Conditional Fields that does have features export capability. I think the UI in this Field Conditional States is much more intuitive and I would prefer to use it.