Home › Forums › General Issues › Datepicker to text field › Reply To: Datepicker to text field
I’ve usually done this with a date picker field that isn’t required then an alternative free text field. On the front end, I’ve then had it checking for whatever should be the priority first then falling back to the other field type. Then in the backend on the prioritized field, I usually note in the instructions that if the field is populated, it will take priority over the other.
So maybe you have a text field that is called something like Starting Date and then a date picker field called Exact Start Date and you note that if the exact start date is populated, it will take priority over the starting date text field (in case someone populates both and you only want one)
Something like:
$exactDate = get_field('exact_start_date');
if ( $exactDate ) {
echo $exactDate;
} else {
// the text field
the_field('starting_date');
}
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.