Multi select dropdown list in form builder

Sylvain C. asked on May 21, 2020 03:14

Good morning, I am using form builder in my MVC site which works fine. However, I am missing 2 components: * I would like to have a multi select dropdown list to choose multiple choices. The one available by default in the form builder is only for selecting one choice. * Just a generic label component to provide text explaining part of the form, ideally a rich text. Does any of you would have some directions to implement these 2 components?

Thank you

Sylvain

Recent Answers


Dmitry Bastron answered on May 21, 2020 09:50

Hi Sylvain,

Have a look at the documentation and the example Form Component first, it should give you a good start. In terms of multiselect form component, I'd recommend Chosen plugin on frontend.

0 votesVote for this answer Mark as a Correct answer

Sylvain C. answered on May 21, 2020 22:22

Thank you Dmitry for your links, it was very helpful.

I was able to follow the examples and created my first form component. In my case, I need a dropdown list whcih is based a value provided by the editor.

However, I have a special case:
I have a registration form per event.
Each event contains several meetings and each attendee can attend one or several meetings during the event.
I need to have a multi select checkbox list or a multi select dropdown list where all the meetings within this event will be listed and the attendee will be able to select the ones he has interest to.

The code for the event is contained in the form title and I have already all the code to extract all the meetings within an event.
Is there a way to either provide a value to the form component to generate that list or a way in the form component to pick up the name of the form?

I looked at the example in the API with BizFormInfo but the name is coded in hard and not extracted from the form where the form component is included into: BizFormInfo formObject = BizFormInfoProvider.GetBizFormInfo("ContactUs", SiteContext.CurrentSiteID);

0 votesVote for this answer Mark as a Correct answer

Dmitry Bastron answered on May 22, 2020 10:27

In the documentation there is another example covering scenario similar to yours: it's a dynamic listbox and all you need to do is to implement GetItems() method with your custom logic. The only difficulty is that from this method you can't read values from other form components. So I guess you would need to save your event code in request context on the beginning of your request then read and use this code from context in GetItems method.

0 votesVote for this answer Mark as a Correct answer

Sylvain C. answered on May 22, 2020 20:36

Thank you Dmitry, I had already followed this example to construct the multi select list.
However, this example always returns the same list (all pages of the 'DancingGoatMvc.Article' page type located under the 'Articles' section).

In my case, I need to generate this list based on a parameter (either provided by an input to generate the list or by getting the name of the form). I didn't find any example to do that...
Could you please also elaborate on saving the event ID in the context, how can I do that? Should it be done when the form loads?

Thank you

Sylvain

0 votesVote for this answer Mark as a Correct answer

   Please, sign in to be able to submit a new answer.