sulu/SuluFormBundle

Conditional form fields

Opened this issue · 2 comments

Q A
Bug? no
New Feature? yes
Bundle Version Specific version or SHA of a commit
Sulu Version Specific version or SHA of a commit
Browser Version Browser name and version

Actual Behavior

You can use dropdown form fields with multiple answer possibilities. However, in the back-end it is not possible to have follow up questions depending on the answer given in a previous dropdown question.

Expected Behavior

A conditional form field that is only shown in the front-end for the user to fill in, when a specific option is selected in a previous/referred dropdown form field.

Steps to Reproduce

Question 1: What color do you like most?
Options: Red | Blue | Orange | Yellow

Conditional form field:
If Question 1 = Orange
Question 1A: What is your most favorite orange item?

That sure an interesting Idea but I'm not sure if the SuluFormBundle is the right fit for this kind of complex forms. As such forms goes into direction of Wizards. And what the SuluFormBundle is not build for is to create forms for Business Logic. It is more the quick content manager forms for Contact Us, Help Desk, ... .

If the Form represent Business Logic it should be part of the Code and not a form managed by content manager.

Keep still in mind the SuluFormBundle is at the end just a Symfony Form and there as nothing which has more hooks and events to hook into then the symfony/form component. And you could so still create such things in a project or put it into a bundle as an extension.

What kind of forms do you want to create? And what is happening with the submitted data over this kind of forms?

Hi Alexander. Thanks for the reply. I wish I could program, but I'm just an end-user with no coding skills (though, I must admit I can understand HTML a bit.....cough). ;-)

I desperately need this functionality in the forms I create in the back-end. Unfortunately, conditional form fields aren't available. They come in very handy to keep your forms short, presentable and logical. Hiding questions that are irrelevant for the visitors of our website, will make the forms less complex to fill out. Here is a form I now configured together in the back-end: https://www.eurol.com/en/lube-check

Scroll down to the Equipment part. You'll see a question in where is asked to select the equipment part. Then a bunch of follow-up questions are already visible, while only one of them is relevant (depending on the answer given in the Equipment part question). And it should be required to because it is vital information for us, but I can't make them required now. This is because only one of them is possible for the visitor to answer. So now I need to notify the user in advance to only answer the follow-up question that is applicable for them, which is a hideous situation and sensitive to errors.

Again, I'm not a programmer. Just dropping this feature request as an end-user, hoping it will come available in the future. :-) Don't know this is the place to do this. If not, then sorry.