Hi all,

Feature needed for my current project and seems to be interested for this module - conditions constructor. There is need to be able to build from GUI arbitrary complexity logical expression including NOT AND and OR operators.

Patch to be provided shortly

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

ogorun’s picture

Status: Needs review » Active

Sorry for previous invalid status. Status is changed to active

ogorun’s picture

Here is a patch for review with implemented feature.
I prepared jquery plugin le (logical expression) that includes $.le.expression class with API for expression building and evaluation, $.fn.leConstructor plugin component with GUI for conditions constructor and $.fn.leConditionalForm plugin component for client-side conditional form processing. This javascript was main work to get module work with complex expressions. After client-side build serialized expression is stored in hidden field representing one of component properties.

There are two more changes in patch that need to be discussed.

1. Since plugin works currently with operations =, >, <, >=, <=, 'starts from', 'ends with', 'contains','empty', 'one of' (and this set is customizable), I don't see sense to restrict trigger fields just to selects/radios. So I let any type of component except 'pagebreak' to be a trigger (but not select options that allow multiples)

2. There was preparation in code of module to functionality of optional mandatory fields - fields, that should be considered mandatory in case they are visible. I completed this functionality in following way. To avoid chains of expression evaluation on both client- and server-side, all evaluation is done only on client side and pass fields that need to be considered as mandatory in current situation through hidden field.

This variant is tested with module Webform in versions 2.6 and 2.9 currently

I'll be glad to hear any feedback

ogorun’s picture

Status: Active » Needs review
Marat’s picture

I tried it with Webform 3 and got this error:

Fatal error: Call to undefined function webform_load_components() in /home/sites/all/modules/webform_conditional/webform_conditional.module on line 179

Marat’s picture

I tested it with Webform 2.9, it works fantastic. It has so nice functions, thank you very much @ogorun!

Please keep going with this one, it is really awesome.

ogorun’s picture

Status: Needs review » Needs work

Thank you for feedback, Marat. I'll test things with Webform 3. It seams these version have incompatible API.

Marat’s picture

I found it works with only the first component of webform; however, it does not work properly in the second component and so on.

What happens, the first choice of the dependent component (here is multiple selection) is hidden instead of the independent components. This occurs only in the later components.

ogorun’s picture

Hi Marat,
Please give me more details about this problem with components order because I use this patch with differently placed components and didn't meet such situation. An as I could noticed work with inheritances of dependencies. The only thing I can notice now is that multiple selection is not supported (like in original webform_conditional module).

Please describe the situation you meet the problem.

Marat’s picture

Sorry @ogorun, I think I mixed up. I used numbers for the "Field Key", but when I changed to letters, it works well. Please accept my apologies for distracting you.

ogorun’s picture

Status: Needs work » Needs review

Since Webform 3 already has own conditional fields engine and Webform Conditional module is on the way to be merged into it, it's more logical to speak about this feature as part of Webform module and not of Webform Conditional. So I submitted patch to Webform issue (see issue Merge Webform Conditional into Webform (support for same-page conditional fields)) and don't plan now to update patch for Webform Conditional module in order it to be able to work with Webform 3. This patch is considered for work with Webform 2 (if such solution is interesting for anybody).

So I revert status to 'needs review'

tedbow’s picture

Status: Needs review » Closed (works as designed)

I have changed the setting module to add the "operator" field similar to the main Webform module. I think it is best to keep the settings as similar to the main Webform module as possible.