Is this possible? Dynamic display of content in an Entityform/Webform based on dropdown list choice

Events happening in the community are now at Drupal community events on www.drupal.org.
frankdesign's picture

Hi all

I'm working on a appointment booking form and I'm trying to implement some dynamic functionality in the form. I've tried both Entityform and Webform but I can't seem to get either work for me.

Basically, the form is a simple booking form - no payments required, only name, email, preferred date and time of appointment etc.. There is also a dropdown list of Treatment types to choose from (which my client will want to edit and update on a regular basis). The bit I can't get working is when the user chooses say Treatment A from the dropdown list, I want to be able to display other details about Treatment A, like the Special Offer Price, the Original Price and a description of the Treatment etc...

What I have tried so far is to set up a Treatment BEAN Type to hold all the values of each Treatment (using Taxonomy for the Treatment Type). For my first attempt, I tried to integrate that with Entityform by creating a view of the Bean, Expose the Treatment type as a filter and add that to the EntityForm as a Field_Embed_Views field, but that module does not support exposed filters. Then I tried using Entity Reference and EVA, but from what I can see, EVA does not work on Entity Forms before submission (it only works on the submissions from the form). I was then thinking that I could have my View with Exposed Filters as a Block on the Entityform and somehow populate a hidden field with the Exposed View Choice when the form is submitted - but I can's seem to figure out if that is possible.

Has anyone got any other ideas/solutions - using either Webform or Entityform?

Thanks a mil

F

Comments

How about

Hi Frank

luisrc7's picture

Hi,

I remember our clients could achieve something similar just with Webform, and as this module say: https://www.drupal.org/project/webform_conditional
Since webform 4.x is included in the webform module, so you can create dependencies between fields.

If that doesn't work I used before Conditional Fields(https://www.drupal.org/project/conditional_fields) and a similar module called Field Conditional State(https://www.drupal.org/project/field_conditional_state). These two modules would work with Content Types.

I hope it helps,
Luis.

Webform conditional fields

stella's picture

Hi Frank,

We've done something similar with webform conditional fields, like Luis is suggesting. Basically you create a whole bunch of markup webform fields where you store your data. Then at the bottom of the markup field you expand the "conditional fields" fieldset at the bottom of the page and you can configure there the trigger field (your treatment drop-down) and the value from it (note, value/key, not the label) that will trigger the visibility of the field.

Cheers,
Stella

Thanks everyone for your

frankdesign's picture

Thanks everyone for your suggestions. I had looked at Webform Conditional before but as my client currently has 30 treatments and on a monthly basis might be adding or removing 10-20 treatments, I felt that he would likely mess it up as the Webform UI is not very user friendly for those who are not techie.

But I found a solution this morning. There is a module called Exposed Filter Data which outputs the Exposed Filter value via the function get_exposed_filter_output();. The default tpl file which comes with the module adds a load of div's and classes, so I copied it to my templates, stripped all the excess mark-up which left me with just the value from the exposed filter. I then created a module to prepopulate a webform field with the value from get_exposed_filter_output(); and hey presto - I now have a view with an exposed filter on the Webform, which when I choose a treatment from the dropdown, populates a field in the form with the chosen treatment.

Deadly schmeadly!

Frank

Ireland

Group notifications

This group offers an RSS feed. Or subscribe to these personalized, sitewide feeds: