TOPIC:

Accordion 1 year 10 months ago #238667

  • Topic Author
  • Neppert
  • Offline
  • Junior Breezer
  • Junior Breezer
  • Posts: 29
  • Thanks: 0
Hi,
I would like to create a form with many items on one page and would like to have an accordion functionality to structure it. A year ago you were up to create a feature for that. I cannot find it right now.
Is there a possibility for that effect?
Regards,
Katja

Please Log in or Create an account to join the conversation.

Accordion 1 year 10 months ago #238674

  • mihaela
  • Offline
  • Developer
  • Developer
  • Posts: 3128
  • Karma: 105
  • Thanks: 415
Hello,

Accordion functionality to structure a form is not a default BreezingForms feature.

The best solution that I can suggest that can be similar to this functionality is to implement in your form visibility rules.
You could put elements that should show/hide together in section and the turn that section on and off based on, for example, if a checkbox is checked, or based on radio group selection.
Here is a piece of documentation explaining how to set visibility rules crosstec.org/en/support/online-documenta...f-conditionally.html .
Also, this is a useful video crosstec.org/en/support/online-documenta...sections-on-off.html .

Furthermore, I have tried to make a quick solution to implement accordion functionality, but it requires quite a bit of coding.

But if you wish to implement here are instructions on how to make this work:

1) Go to your form's Advanced properties > More options > Scripts > Initialization script and set Type to Custom.
In the code area that appears put the following code:
function ff_AccordionForm_init()
{

JQuery('#bfPage1').prepend('<button class="accordion">Section 1</button><div class="panel" id="sec1"></div><button class="accordion">Section 2</button><div class="panel" id="sec2"></div>');

// Add to section1
jQuery("[name=\"ff_nm_field1[]\"]").parent().detach().appendTo("#sec1");
jQuery("[name=\"ff_nm_field2[]\"]").parent().detach().appendTo("#sec1");

// Add to section2
jQuery("[name=\"ff_nm_field3[]\"]").parent().detach().appendTo("#sec2");
jQuery("[name=\"ff_nm_field4[]\"]").parent().detach().appendTo("#sec2");



var acc = document.getElementsByClassName("accordion");
var i;

for (i = 0; i < acc.length; i++) {
  acc[i].addEventListener("click", function() {
    /* Toggle between adding and removing the "active" class,
    to highlight the button that controls the panel */
    this.classList.toggle("active");

    /* Toggle between hiding and showing the active panel */
    var panel = this.nextElementSibling;
    if (panel.style.display === "block") {
      panel.style.display = "none";
    } else {
      panel.style.display = "block";
    }
  });
}
} // ff_AccordionForm_init
NOTE: In the code above you have to replace AccordionForm with the actual name of your form.
Furthermore, you have to replace field1, field2, field3 and field4 in pieces of code like this:
jQuery("[name=\"ff_nm_field1[]\"]").parent().detach().appendTo("#sec1");
with the actual names of elements in your form.

Furthermore, this is a code adjusted form BreezingForms theme. The code for Bootstrap theme would be a bit different.
In case you are using Bootstrap theme engine, this code:
// Add to section1
jQuery("[name=\"ff_nm_field1[]\"]").parent().detach().appendTo("#sec1");
jQuery("[name=\"ff_nm_field2[]\"]").parent().detach().appendTo("#sec1");

// Add to section2
jQuery("[name=\"ff_nm_field3[]\"]").parent().detach().appendTo("#sec2");
jQuery("[name=\"ff_nm_field4[]\"]").parent().detach().appendTo("#sec2");
should be replaced with this one:
// Add to section1
jQuery("[name=\"ff_nm_field1[]\"]").parent().parent().parent().detach().appendTo("#sec1");
jQuery("[name=\"ff_nm_field2[]\"]").parent().parent().parent().detach().appendTo("#sec1");

// Add to section2
jQuery("[name=\"ff_nm_field3[]\"]").parent().parent().parent().detach().appendTo("#sec2");
jQuery("[name=\"ff_nm_field4[]\"]").parent().parent().parent().detach().appendTo("#sec2");
According to this example you can add more sections and elements to sections.

2) Go to your form's Advanced properties > More options > Form Pieces and in the Before Form section set Type to Custom.
In the code area that appears put the following code:
echo '<style>


.accordion {
  background-color: #eee;
  color: #444;
  cursor: pointer;
  padding: 18px;
  width: 100%;
  text-align: left;
  border: none;
  outline: none;
  transition: 0.4s;
}

.active, .accordion:hover {
  background-color: #ccc;
}


.panel {
  padding: 0 18px;
  background-color: white;
  display: none;
  overflow: hidden;
}

</style>';

That will do the trick.

One last suggestion is to apply this solution to your form crosstec.org/en/forums/3-breezingforms-f...-process.html#206383 . In that case, you would have more pages in your form, but you could skip from page to page using tabs.

I hope one of the solutions will work for you.

Let me know whether this helped.

Regards,

Mihaela
The following user(s) said Thank You: Neppert

Please Log in or Create an account to join the conversation.

Last edit: Post by mihaela.

Accordion 1 year 10 months ago #238679

  • Topic Author
  • Neppert
  • Offline
  • Junior Breezer
  • Junior Breezer
  • Posts: 29
  • Thanks: 0
Hi Mihaela,
thanks a lot - I tried it and it worked!
Best regards,
Katja

Please Log in or Create an account to join the conversation.

Accordion 1 year 10 months ago #238683

  • mihaela
  • Offline
  • Developer
  • Developer
  • Posts: 3128
  • Karma: 105
  • Thanks: 415
Hello again,

Great! I'm glad that it worked.

Regards,

Mihaela

Please Log in or Create an account to join the conversation.

  • Page:
  • 1
Moderators: ForumSupport
Time to create page: 0.116 seconds

BreezingForms Pro 1.4.7 for WordPress Released!

Available in the membership section.

September Discount!

Massive discounts on all subscriptions!

Get Your Subscription Here

Quick Links

Downloads

BreezingForms

ContentBuilder

BreezingCommerce

Templates

Documentation

BreezingForms

ContentBuilder

BreezingCommerce

Apprendre BreezingForms (French Community)

Apprendre et maîtriser BreezingForms par des tutoriels et exemples, le tout en français

breezingforms.eddy-vh.com

Questions et réponses sur les forums de l'AFUJ

AFUJ

Special Offer

Summer Sale! All subscriptions at a special price!

Includes prio support, all of our current and future Joomla!® extensions and Joomla!® templates for the duration of your membership.

Get it from here

3rd Party Discount - 25% Off

We help you to keep your costs under control. If you are a new member and purchased a form building tool from a different form vendor, then you'll get a 25% discount on our subscription plans.

How to receive the discount:

Send us a quick email to sales@crosstec.org with a proof of purchase (for example a paypal receipt), await payment instructions and enjoy your membership!