Skip to main content
Håkon_Rød
Level 2
Mar 2, 2021 10:27 AM UTC
Question

Form fill - overwrite fields when the values are blank

In some forms we want the open text field to be overwritten when the values are blank.

How can we achieve that?

7 replies

Jay_Jiang
Level 10
Mar 2, 2021 12:27 PM UTC

with some mktoForm js you could change the field values to be "NULL" on submit if the field value is empty

Translate
Vinay_Kumar
Community Advisor and User Group Leader
Community Advisor and User Group Leader
Mar 2, 2021 1:37 PM UTC

To achieve this:

you can set default values.

or 

you can use JS

Translate
SanfordWhiteman
User Group Leader
User Group Leader
Mar 2, 2021 4:24 PM UTC

The problem with simply setting the value to NULL using JS (and it's even more obvious if you set a default value) is the user sees the word NULL, which looks unprofessional IMO.

 

I have a blog post coming out next week where I show how to set the value to NULL while the field still looks empty to the end user (and no, it doesn't use a hidden field!).

 

In other words, instead of this confusing experience:

 

 

This smoother one:

 

Translate
Jay_Jiang
Level 10
Mar 2, 2021 11:27 PM UTC

Ah yes, I admit I forgot that the form field is still visible for a split second when you change values that way.

 

I would then probably just use js to add hidden fields for the fields that are empty and set the values of those to NULL. It might be hacky but I think it should work.

Translate
SanfordWhiteman
User Group Leader
User Group Leader
Mar 3, 2021 12:15 AM UTC
That'll work fine, though requires a proxy for every field that might be blank-able. I think you'll like my technique when it comes out.
Translate