Contentful logo

Contentful Community

Ability to have a default value for a radio button / Boolean field

default_field_values
#1

I had a query on radio buttons and Boolean fields. Currently we can give options Yes and No using these options, but there is no way to default a value for an option and the user has to select an option. Need some help on this, is there a way to default the value to let’s say “Yes” all the time unless someone wants to change the value?

Eg:
Lets say it is a survey question - “Have you given a rating” ( ) yes ( ) No ] - this is how it is shown with the existing fields. Would it be possible to show it like
"Have you given a rating" (X) yes ( ) No Clear ?

7 Likes

#2

Hey @ngandhi ,

First of all, thank you very much for joining our Contentful Community!
Unfortunately, it’s not possible at the moment. What you’re talking about is default values for fields. That’s very useful feature and I completely agree with you. We are aware of that and discussing how we can address it.

Please let me know if I can help you with anything else.

0 Likes

#3

I would very much like to see defaults, too.

0 Likes

#4

We also have interest in such feature. Currently with multiple locales we risk to pickup the value of a fallback locale. Which is not desired in our use cases.

0 Likes

#5

Up-voting this feature! Default values would be very helpful.

0 Likes

#6

I second this! Actually, I just sent a feature suggestion to Contentful’s support few days ago.

In this particular case, I had to add a boolean field to a content model which was used for several hundred entries. Going through all those entries manually one by one wasn’t an option, so I had to write a script utilizing the Management API that goes through all the entries of that particular content model and sets the desired value.

My biggest gripe with the boolean field type and the lack of default value is that it’s actually triboolean (true/false/null). Moreover, the way the Web App displays true and null values as “No” is confusing.

0 Likes

#7

I’ll +1 this feature. The triboolean doesn’t make any sense. This is also a very common field type in many other CMS so I imagine most customers are going to expect this type of field.

See this example of “Hide from search?”

0 Likes

#8

Here’s the workaround I came up with. It’s limited to boolean fields and requires that you treat null/undefined as equal to false. In that case, you just have to formulate the field label so that the default condition is met when the field is undefined/null.

Another (mild) workaround is to mark your boolean field as required. That should provide only true/false values, but only for Published entries in the Delivery API. You may still encounter null/undefined values in the Preview API.

0 Likes