Complex form element


I want to build form, where will be two selection inputs. One of them gets data immediately from service and the other one gets data from service based on selected value in previous. So it's like "Pick country" -> "Pick city". Don't know which solution is the best, but I think that this should be one complex form input block with two blocks inside. But it seems that it's not possible because epiforms "understands" only children form inputs. Please, help.

Nov 07, 2017 14:43

A S,

I moved your post to the Forms forum.

Edited, Nov 07, 2017 18:21

It is possible to create custom element with 2 blocks inside then do your business. Please see the Address and DateTime element in samples project here:

Note that you might need to override the method getCustomElementValue to return data from your custom element in format you want.

Hope this help.

Edited, Nov 08, 2017 5:15

Thanks, that's a lot help, I dont know how I would come to this alone. However, getCustomElementValue doesn't do exactly what I want. I want that every field inside block sends separately. For example, it's working like this:

{Address:{Country: USA, City: NY}}. And I need this:

{Country: USA, City: NY}.

This is why I tried to put two form blocks inside another. Is there a workaround?

Nov 09, 2017 13:50

I've got the same problem. I'm having to do my address as one field, but I'd really like to save each part of the address as a separate field when the form is sent.

Nov 09, 2017 13:55

You can return your data in any format you want. You can override the method GetSubmittedValue() in your custom element to do that. Please see that method on the file AddressElementBlocks.cs.

Nov 10, 2017 3:30

Like I said, this method is responsible for "{Country: USA, City:NY}" but when form is submitted, the result is "{Address{Country:USA, City: NY}}.

Nov 10, 2017 6:45

I mean, instead of using the sample serialize object, you can modify code to serialize the object yourself then you have full controlled how the returned object should look like...

Nov 10, 2017 7:36

Not the full controlled. I dont need "address" part in response

Nov 10, 2017 8:23

The "Address" is your element's name and its value is a json object in the right part. Let say you have 2 elements: Address and Email, you need something to know which data belong to the Address and which belong to the Email. Right? If you only need to send the value WITHOUT element name, you can create your custom actor then do yourself. The default CallWebhookAfterSubmissionActor can sent in JSON format or "name=value" format.

Nov 10, 2017 8:43
This topic was created over six months ago and has been resolved. If you have a similar question, please create a new topic and refer to this one.
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.