Home › Forums › General Issues › Set a blank custom field value as default
Hi,
A little background: I’m using custom fields to store software specifications in each post.
I’m trying to replace the Custom Field Template (CFT) plugin with your plugin, but I’ve run into a problem. With CFT, True/False values default to “Select” so I know which custom fields I haven’t set. But with Advanced Custom Fields, there’s only a checkbox, which leaves me with no way to tell which fields I’ve set. Another problem: if I add a custom field, it will default to “False”, since the checkbox is unchecked.
I’ve tried to use a “Select” box, but that leaves me with the same problem. The default value is “True” rather than “Select” or empty. So if I add a custom field I have no way of knowing which previous posts need their custom fields set.
Is there any way around this? Thanks very much for your time.
Regards,
Geoff
Hi @Geoff
I don’t understand what you mean by “The default value is “True” rather than “Select” or empty”
When editing, the select field will load the default value or just appear with the topmost value selected.
I’m sure there is a way you can work with this.
Elliot,
Sorry for the complicated question. It’s probably easier to explain with a screenshot 🙂
As you can see, the default value for the select box is “Select.” So if I create a new custom field, then come back to edit this post, I can tell I haven’t set that custom field before. Whereas with your plugin the default is “True” and I have no way of knowing if I set it to “True” or not. Does that make sense?
Hi @Geoff
Unless there is a massive bug I am unaware of, the value should not default to ‘True’. If no value is found in the DB, it will be read as null.
Perhaps you have a custom filter which is setting this?
When using a select field, the first option will be selected if no value is saved. This is default HTML logic
Yeah, I was referring to the select box only, not the value (sorry if that was unclear).
So for my situation, should I just make the first option “Select” followed by “True” and “False”? That way I could tell which custom fields are blank.
Also, is there a way to decrease the width of the select box in ACF?
Hi @Geoff
Yes, the select field contains an option to allow for a null selection.
This adds a ‘- select -‘ option which you can use to see the difference between null and true.
To decrease the width, please use CSS in the admin
Thanks
E
The topic ‘Set a blank custom field value as default’ is closed to new replies.
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Privacy Policy. If you continue to use this site, you consent to our use of cookies.