I am using Webform Conditional Actions module, created my webform exactly how I wanted using the module. When I view the webform within the webform's page the conditionals work great and hide the fields that are supposed to be hidden. But, I am also using UberCart Webform Checkout Pane module which allows me to add a created webform on my drupal site to the checkout form, so a customer has to fill out the form when checking out. The conditional actions are not carrying over in the checkout form. It shows all of the fields, they are not hidden. Has anyone else experienced this? do conditional actions not carry over to the webform checkout pane module? I assumed they would because they are part of the webform and alls the UberCart checkout pane module is doing is allowing me to include an already created webform to my product's checkout form.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

HunterT’s picture

Title: Conditional actions do not work within UberCart checkout pane? » Conditional actions do not work within UberCart checkout panes module?
tedbow’s picture

Category: task » support
Priority: Normal » Minor

HunterT

can you provide a link to "Webform Conditional Actions module"?

HunterT’s picture

Well I am using 4 modules

UberCart and UberCart Webform Checkout Panes http://drupal.org/project/uc_webform_pane
Webform and Webform Conditional (which is your module) http://drupal.org/project/webform_conditional

Now your Webform Conditional module helps me create a webform exactly the way I want it. It looks like this:
What sport will you be using this for?
----(dropdown list of different sports: Football, Hockey, Golf etc...)
Where did you here about us?
----(dropdown list of different references: Website, Phone, Sales Rep, Service Center etc...)
Please let us know which sales rep informed you:
----(long dropdown list with many sales rep names)
Please let us know which service center you visted:
----(long dropdown list with many server center names)

With your module I was able to make it so "Please let us know which sales rep informed you" and "Please let us know which service center you visted" are hidden and only appear depending on which one is selected within "Where did you here about us?"
When I view the form from the webforms page (the page under Admistration > Webforms) it works perfectly showing only the first 2 questions on the form. The conditionals work!

Here is the problem:

The Ubercart Webform Checkout Page module simply just lets you take any webform that is created on your site, and add it to the UberCart checkout form so the customer has to fill out the webform (Customer Survey) when they fill out all of their billing info, name address, shipping method etc. This is set by going to UberCart's Configurations Page > Checkout Settings > Checkout Panes - On this page there is a list of all of the fields that appear on the checkout screen so you can select or deselect which ones you want. Because of the "UberCart Webform Checkout Panes Module" my webform named "Customer Survey" appears on this same list so I can just put a check in its box to make it appear during checkout also. But when I test this out by adding something to my shopping cart and proceeding to checkout page I noticed that the webform is there but the conditionals are not working. I see all 4 questions just how they appear at the top of this post. The last 2 are not hidden like they should be.

My only guess is that when "UberCart Webform Checkout Panes Module" pulls the webform into the checkout pane, it isn't pulling the conditional statements with it, or it is reading the conditional code in a bad order.

Sorry I wrote so much, I just don't know how familiar with the modules that I am using. Please let me know if you have any advice for me, a fix, or an alternative solution to my problem. You help is greatly appreciated.

ravipjoshi’s picture

I too would be interested in seeing this work.

tedbow’s picture

I have not installed "uc_webform_pane" but I took a look at the code.

I think that main problem is that uc_webform_pane creates the webform components individually it doesn't use drupal_get_form or the form API. I could be wrong. Therefore the hook_form_alter in webform_conditional is never called.

Like I said didn't actually install it. That is just my idea from looking at the code. Right now getting this to work is not a top priority, sorry.

There is another similar module you could try: http://drupal.org/project/uc_webform

I haven't tried this one either though.

ahkiam’s picture

I too am interested in this feature when/if it moves up the priority list.

Dubber Dan’s picture

subscribing as also interested

quchidru’s picture

subscribing - also interested

praddles’s picture

Subscribing too

chinita7’s picture

The similar issue in webform checkout pane module is here http://drupal.org/node/1064316#comment-5751860

arski’s picture

@maintainer: I've applied some changes to uc_webform_pane so that it calls the form hooks. However, the issue now seems to be in the different placement of the webform elements inside the big ubercart checkout form - see also http://drupal.org/node/1064316#comment-5269302 - lemme know if I can help any further.

arski’s picture

Category: support » bug
Priority: Minor » Normal

Bumping this to a bug report as the issue here are hardcoded paths in this module that others can't do much about. Let me know what your thoughts are on this (see the link in my previous comment for more details from the uc_webform_pane side).

Thanks

tedbow’s picture

@arski, if I understand the problem, I think a flexible solution would be to let other modules alter the css id that this module uses for elements.

I have attached a patch that creates a new hook - hook_webform_conditional_css_id_alter
This allows your module to change to change the css_id that my module will use for every element.

I have just tested that this patch doesn't break this module. I have not tried to implement the hook. Please let me know if it works for you.

tedbow’s picture

Version: 6.x-1.0-beta6 » 6.x-1.x-dev
Component: Miscellaneous » Code
Category: bug » feature

Changing to 6 dev version, etc

tedbow’s picture

Status: Active » Needs work

@arski, actually after thinking about this the current patch it is probably not the best performance wise. I think there should be just one drupal_alter call to for the whole form to change all the ids at once. Otherwise for forms with tons of components the drupal_alter will be called tons of times, whether not they have any modules installed that actually implement it.

Just fyi I am working on a different patch.

tedbow’s picture

Status: Needs work » Needs review
FileSize
5.17 KB

ok attached new patch. hook is now hook_webform_conditional_css_ids_alter

So it is just called once to change all css ids.

Please let me know if this works for you. Would you need the $form_state also passed to the hook?

arski’s picture

Hi, nice one. I think I was able to implement the hook and make your .js work with the different field ids inside the checkout pane.

The whole thing did, however, break the checkout, so I'm not signing off on it just yet, but it looks good. I'll look into the cause of further issues tomorrow. Thanks again.

arski’s picture

Status: Needs review » Needs work

Right, so mainly this works quite nicely. The JavaScript bit integrates flawlessly for sure.

What I needed to hack around a bit was the after_build function. I pretty much have a solution, though it requires for the ucwp module to have a higher weight than yours (so that I could replace the after_build function). I can do that, but usually it's best to avoid changing the weight..

There is one alternative fix that should be completely harmless. Would you mind adding a check like
if (sizeof($submitted_values)) { ... } after $submitted_values = _webform_conditional_get_submitted_values($form_state); around line 210 of webform_conditional.module for the rest of the code in there.

Since the values of a webform pane are slightly in a different place, the $submitted_values array in there when used inside a checkout pane is simply empty. On a real webform, if nothing is entered, it will have a list of all the elements, with empty values, but the array itself will never be empty.

This would solve the last remaining issues for the integration!

Cheers

tedbow’s picture

Ok

There is one alternative fix that should be completely harmless. Would you mind adding a check like
if (sizeof($submitted_values)) { ... } after $submitted_values = _webform_conditional_get_submitted_values($form_state); around line 210 of webform_conditional.module for the rest of the code in there.

Since the values of a webform pane are slightly in a different place, the $submitted_values array in there when used inside a checkout pane is simply empty.

Ok my question then if "sizeof($submitted_values)" will always be empty in your case doesn't that mean the lines of code that I would be surrounding by the if statement:

  $components = _webform_conditional_get_all_components($form_element['#webform_component']['nid'], $submitted_values);
    $was_hidden = _webform_conditional_was_hidden($form_element['#webform_component']['cid'], $components);
    if ($was_hidden) {
      $form_element['#required'] = FALSE;
      _webform_condtional_clear_element_values($form_element, $form_state);
    }

Would never be executed if it were in a checkout pane? If so then the required flag will never be reset.

Have you tried making a required competent conditional on another component so that it is hidden by default. Then don't fill out that component and see if you get the required error.

  1. So the set would be
  2. Text box A is required.
  3. Text box A is only shown if Checkbox B is selected.
  4. Submit the form with out checking Checkbox B(and therefore no value in TextBox A)
  5. Do you get an error that says Textbox A is required?

Can you test this out b/c I don't have Ubercart Checkout panes installed?

Thanks

arski’s picture

Would never be executed if it were in a checkout pane? If so then the required flag will never be reset.

Yes, that is what I'm actually aiming for. I've created a similar after_build function inside the UCWP that is able to fetch the $submitted_values and then select the right components to hide, based on whatever conditions were picked or not. See at the very bottom of my last commit http://drupalcode.org/project/uc_webform_pane.git/blobdiff/cd0e6ffeb1ed1...

And yes, your scenario works nicely with the adapted after_build function, even tested it with multi-level conditionals :)

Cheers

tedbow’s picture

Ok I added
if (!empty($submitted_values)) {

Let me know if that works for you.

arski’s picture

Status: Needs work » Reviewed & tested by the community

yeah, works like a charm. Marking as rtbc straight away I guess.

Do you plan to apply similar patches to the D7 branch as well?

Thanks for the updates!

tedbow’s picture

Yes I plan to make the changes to D7 branch also. Might not get to it till after the weekend though

chinita7’s picture

#21 works with the latest uc_webform_pane 6.x-3.x-dev as expected on my site. Thanks!

tedbow’s picture

Status: Reviewed & tested by the community » Fixed

Committed to dev

tedbow’s picture

Version: 6.x-1.x-dev » 7.x-1.x-dev
Status: Fixed » Needs review
FileSize
7.74 KB

I have attached a patch for Drupal 7.

@arski and others please test and report back. I will commit it when I here back

Thanks

arski’s picture

Status: Needs review » Needs work

Hmm, doesn't seem to be quite working. When I do alert(triggerField_info.toSource()); after $.each(Drupal.settings.webform_conditional.fields, function(triggerField_key, triggerField_info) { in the .js file, the css_id values in the returned object are still the unchanged ones.

The webform_conditional_css_ids_alter function is being called for sure, and values are being adjusted in it.

arski’s picture

any news on this? :)

densolis’s picture

All,

I am helping Ted with this module and will be talking with him tomorrow (8-30-12). I will bring this to his attention. Either Ted or I will follow up.

Dennis

arski’s picture

Hey again, did you not have a productive talk or what's happening here? :D

densolis’s picture

Issue tags: +response

arski,

I talked to Tedbow just a hour ago. He will look into this and see if he can get it resolved. He did look at the code while I was talking to him and stated it was not a simple fix. He will have to spend a little time on it, but he is working on it.

I'm sorry I don't have a more definitive answer for you.

Dennis

arski’s picture

well this is definitive enough, meaning there is some progress :)

arski’s picture

bump :)

debo7debo’s picture

any fix yet? I'm working on the second site that I need this to work and I was hoping there would be a solution by now.

tedbow’s picture

Sorry I has been along time since I have looked this issue.

It seems like it works with "UberCart checkout panes" for 6.x but the patch about for 7.x still needs work.

Does that seem right?

debo7debo’s picture

Yes 6.x was fixed but I didn't try the last 7.x patch since there were already comments that it didn't work completely right. I'll give it a try & update this thread.

debo7debo’s picture

Nope, that patch does not work. Doesn't even apply right. Did it on 7.x-1.x-dev

tedbow’s picture

Ok thanks for the update

debo7debo’s picture

I also tried a few of the devs and patches all differently and none seems to work. I'm surprised more people didn't have a problem with this.

Mike_s’s picture

none of the dev are working.

ghubika’s picture

Issue summary: View changes

Any news on this thread? :> I would need this function badly. The conditional module is included in webform now, does that simplify or make the issue more complex?