Forum

Thread tagged as: Question

How to suppress form output IDs if fields is left blank?

I have created a form with multiple inputs including text fields and dropdown selections. I need to leave several of these as non required fields. I have placeholders in my dropdown selections types as opposed to having the first option as an automatic choice. The result of this in the back end is that the ID is not submitted for that form group leaving it complete suppressed from the submission. This is actually quite good as it means that instead of displaying the ID with a result of blank on the submission it just displays nothing at all, quite a neat solution.

However is does not seem to be possible to do the same with a text type field or text area type field. Instead if nothing is input then the form outputs the ID for that form field with a result of blank in the back end.

The end result of this is that if someone does not make selections on dropdowns and also does not fill out certain fields. I get inconsistant formatting in the back end. ie dropdown do not diplay anything at all where as fields display the ID with no result. This potentially confusing for a client.

I have managed to get them all displaying IDs by add an allow empty tag to the dropdown select types. But it would be a neater solution if I could suppress all IDs regardless of type if not filled out

Ritchie Stewart

Ritchie Stewart 0 points

  • 4 years ago
Drew McLellan

Drew McLellan 2638 points
Perch Support

Are you talking about the stored form response in the Forms app, or something different?

yes i'm talking about the stored form response which consists of an ID and value. If you have a dropdown selector on a form and also a text field (both with placeholders) and leave each one blank then hit submit. The data in the response that comes through in the back end is inconsistent.

The text field response will show the ID and its value of blank because nothing was filled out. But the drop down selector will not be included in the response at all, not even the ID as though it was not even part of the form in the first place.

You can force the response to display the ID for the dropdown and a blank result by putting an Allow Empty tag in the code so that it behaves in the same way as the text field.

But what I would rather do is to have the text field behave in the same way as the dropdown.

So if the person filling out the form does not fill out the dropdown or the text field, then the response in the back end would be completely blank, with no ID or value being displayed.

Ritchie

Drew McLellan

Drew McLellan 2638 points
Perch Support

I think the way browsers work is that the field is submitted with an empty value, rather than completely omitted.

Seems strange that that is only the case with a drop down selection field and not a text field! You you think that it would be the same for both

Drew McLellan

Drew McLellan 2638 points
Perch Support

It seems not.