Support

Account

Home Forums General Issues Is there a way to set a default value for a timepicker field?

Helping

Is there a way to set a default value for a timepicker field?

  • The title pretty much says it all.

    I have a timepicker field (start_time) that’s optional and only appears if someone has set a value on a datepicker field (start_date).

    I need to sort posts by start_date, and – if there is a value for the start_time field – sort by start_time within the posts for the start_date.

    I don’t see a way to set a default value for start_time when setting up the ACF.

    If there’s not a way to do it within the admin interface, is there a way to do it when retrieving the post meta data?

  • You would need to use the ACF JS API hook time_picker_init.

    Sorry, that’s really all the information I have. I am not familiar with the time picker settings.

    Alternately you can use the acf/prepare_field hook. The date picker field does not have a default value. You would need to set $field['value'] to the default value, for example if the value is empty then set it to the default.

Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.