
I think I should FOREACH a part of the array. ? Is that a correct thinking?
Although this does not work, could you help me please? This is the last part in a long journey to develop my own booking system:
// Apply conditions to fields
add_filter('acf/prepare_field/name=bookings_field_time_session_1', 'yl_check_booking_exeptions_session_1');
function yl_check_booking_exeptions_session_1( $field ) {
// Retrieve option values. Date value should be like: 20200611 (unformatted)
$rows = get_field('bookings_settings_disabled_exceptions', 'bookings');
if( $rows ) {
foreach ( $rows as $row ) {
$option_date = get_sub_field('bookings_settings_disabled_date', 'bookings', false);
$date = date_i18n('Ymd', strtotime($option_date));
$session = get_sub_field('bookings_settings_disabled_session', 'bookings', false);
$arrays =
array(
array(
'field' => 'field_5ed4181bd63dc', // Time field session 1 in the form
'operator' => '!=', // If Value is different, then show the field
'value' => $session, // Compare against option page value
),
array(
'field' => 'field_5ed4178dd63d7', // Datepicker fiels in the form
'operator' => '!=', // If Value is different, then show the field
'value' => $date, // Compare against option page value
)
);
}
if ( $session == '1' ) {
$field['conditional_logic'] = array(
$arrays
);
}
}
// Return
return $field;
}
}

Thanks for looking into my code.
But it still only outputs 1 condition (session / date combi) although I have 3 entries in the option page… and the other entries don’t have any effect
This is the condition output I get for for the field:
data-conditions="[[{"field":"field_5ed4181bd63dc","operator":"==","value":"1"},{"field":"field_5ed4178dd63d7","operator":"!=","value":"20200627"}],[]]"
The whole code is this:
// Apply conditions to fields
add_filter('acf/prepare_field/name=bookings_field_time_session_1', 'yl_check_booking_exeptions_session_1');
function yl_check_booking_exeptions_session_1( $field ) {
// Retrieve option values. Date value should be like: 20200611 (unformatted)
if( have_rows('bookings_settings_disabled_exceptions', 'bookings') ) {
while ( have_rows('bookings_settings_disabled_exceptions', 'bookings') ) {
the_row();
$option_date = get_sub_field('bookings_settings_disabled_date', 'bookings', false);
$date = date_i18n('Ymd', strtotime($option_date));
$session = get_sub_field('bookings_settings_disabled_session', 'bookings', false);
if ( $session == '1' ) {
// Add the condition to the field
$field['conditional_logic'] = array(
// the first nested array holds OR conditions
// there would be a separate nested array for each OR condition
array(
// the second nesting is AND conditions
array(
'field' => 'field_5ed4181bd63dc', // Time field session 1 in the form
'operator' => '!=', // If Value is different, then show the field
'value' => $session, // Compare against option page value
),
array(
'field' => 'field_5ed4178dd63d7', // Datepicker fiels in the form
'operator' => '!=', // If Value is different, then show the field
'value' => $date, // Compare against option page value
)
),
array(
// this is an example, if there was an OR condition those would go here
)
);
}
}
}
// Return
return $field;
}

Your conditional logic array is not set up correctly
$field['conditional_logic'] = array(
// the first nested array holds OR conditions
// there would be a separate nested array for each OR condition
array(
// the second nesting is AND conditions
array(
'field' => 'field_5ed4181bd63dc', // Time field session 1 in the form
'operator' => '==', // If Value is different, then show the field
'value' => $session, // Compare against option page value
),
array(
'field' => 'field_5ed4178dd63d7', // Datepicker fiels in the form
'operator' => '!=', // If Value is different, then show the field
'value' => $date, // Compare against option page value
)
),
array(
// this is an example, if there was an OR condition those would go here
)
);
I found a solution for this so I thought I would post it here for the next person who comes along.
If you want to extend the existing class, you use this line:
var Field = acf.models.DatePickerField.extend({
It’s used with the date_time_picker to extend off the date_picker but with some enhancements.
What I’m doing is writing a ui enhancement to the actual date_picker (Client wants a button to easily add 30 days to the date), so I’m using that extend snippet and then applying it back to the actual date_picker. That way my custom code is being run and the date picker popup still works:
(function($) {
var Field = acf.models.DatePickerField.extend({
type: 'date_picker',
// name: 'myprescription_expiration_date',
events: {
'click .date_plus_30': 'onClick'
},
onClick: function( e, $el ){
e.preventDefault();
alert("cat");
}
});
acf.registerFieldType( Field );
})(jQuery);
Totally unrelated to this thread but if you’re wondering what the 'click .date_plus_30': 'onClick' is referring to, I have already registered a bit of extra ui right after the admin panel date picker with:
add_action('acf/render_field/name=myprescription_expiration_date', array( $this, 'custom_admin_render_field_date_offset'), 15);
public function custom_admin_render_field_date_offset($field)
{
echo '<p><a href="#" class="date_plus_30">Add 30 days</a></p>';
}
Same issue here, but with a ‘time-picker’ field.
I tried changing the field to ‘text’ and I had the same issue – it would not store data. All other fields work OK.
Additional info:
I’m on Custom Fields version 5.8.9
The field that is not saving was the first field I created.
I can write data direct into the database and see it in my post. But if I edit the data and update the post, the data it disappears.
I am using the “Advanced Custom Fields” plugin where i have created a “Date & Time picker” for my posts. I am using Essential Grid plugin to display my posts. So i created a meta field that pulls from my “date & time picker”. But it just displays like this on the front end “2020-04-04 00:00:00” no matter what I do.
Checked the whole setup for “date_default_timezone_set” and removed them.
Problem still occurs in the date picker.
It gets even more weird, look at the month of the date picker and the corresponding source code

functions.php only related time stuff is the following code
date_default_timezone_set('Europe/Berlin'); // Lokalzeit
setlocale(LC_TIME, array('de_DE.UTF-8', 'de.UTF-8'));
The following jQuery snippet will block all days except Friday (I’m using it for a week-ending form).
You could try returning the day of the week (in this case 5) or the date as a PHP variable from an ACF custom field.
https://stackoverflow.com/questions/19395558/highlight-disable-specific-days-in-jquery-ui-datepicker shows examples of formatting for specific dates.
jQuery(document).ready(function() {
$datepicker = jQuery('.rdsn-week-ending .hasDatepicker');
$datepicker.datepicker( 'option', {
beforeShowDay: function(date) {
if (date.getDay() == 5) {
return [true, ''];
} else {
return [false, ''];
}
}
});
});
This did the trick for me too! Same situation with a custom Date Picker field for events. Everything was coming back as false when I used get_sub_field() but get_post_field() got my true values to appear as they should.
They are Date Picker fields.
Hi there.
I did run in some kind of a pickle.
ACF
wordpress 5.3.2
php 7.0 / 7.1 / 7.2 / 7.3
I’m using a field ‘pst_date’ od type date (with date picker).
On blog edit, I set the value as ‘03.05.2020’. (Format: ‘d.m.Y’ for in- and output)
I know date is saved as ‘Ymd’ in DB and formated on output acordingly.
In the template using:
<?php echo get_field('pst_date'); ?>
output shows ‘02.05.2015’.
I proofed the DB entry: ‘20200503’ is set correctly.
I pretend not to care about the format, so I set output format to ‘Ymd’
output shows ‘20150502’.
So I fiddled around with other values and got the last Sunday of March as the culprit.
before the ‘29.03.2020’ the output is correct after that output is one day short.
Of course I tested it with different years same output.
DST problems with get_field of format date? WTH? Whats up with that?
Using code snippets from documetary:
Input: ‘03.05.2020’ input-format ‘d.m.Y’ output-format ‘Ymd’
$date_str = get_field('pst_date', $event); // '20200502'
$date = DateTime::createFromFormat('Ymd', $date_str);
$mnth = $date->format('m'); // 05
$month = $date->format('M'); // May
$month = date_i18n('M', $date->getTimestamp()); // Mai
$day = date('d', $date->getTimestamp()); // 02
$day = date_i18n('d', $date->getTimestamp()); // 01 now we are even 2 days short???
How can I fix this with using date picker?
Will I have to switch ‘pst_date’ format to ‘String’?
I can’t be the only one with that pickle!!!
Wordpress time zone set to Berlin/Germany
DST switch 29. März 2020 0:00
Here we have an indicator, but why is there a date conversion?
On March 29. the clock is turned forward at 2am to 3am so why are we loosing a day?
How can I get get_field to use stored values at is?
And how can I get php date functions to behave apropriately?
‘Google was no help!’
Or do we have to fix conversion of date in date_picker?
not to use Ymd 00:00:00 but add 2 or 3 hours (Ymd 02:00:00)
for the output foramating process?
Thank you very much.
It’s been a while! But a tip: if the dates have been saved by a date_picker field and not a date_time_picker field in Ymd format (for example 20200916), you’ll need to convert the values in the database to a machine-legible date string (Y-m-d) before integrating this solution. Otherwise, the dates will all be displayed as 1970 dates, and potentially saved with incorrect values when re-edited.

There have been a few topics about date fields like this one https://support.advancedcustomfields.com/forums/topic/date-picker-fields-in-repeaters-gone-wrong-after-wp-5-3-update/ I can’t seem to find others at the moment, but the issues seem to all resolve around attempting to set the time zone in PHP.
hello @lefthookdigital
i read above thread, i have solution to display fileds along with “_name” and copy it by one click
demo >> http://prntscr.com/r00zwx
in functions.php add below code
/*
|--------------------------------------------------------------------------
| acf admin slug
| https://www.advancedcustomfields.com/resources/acf-render_field/
| https://www.coderomeos.org/select-and-copy-data-to-clipboard-using-jquery
|--------------------------------------------------------------------------
*/
add_action('acf/input/admin_footer', 'my_acf_input_admin_footer');
function my_acf_input_admin_footer() {
if ( get_post_type() != 'acf-field-group' ) { ?>
<script type="text/javascript">
jQuery(function($) {
$('#wpwrap').each(function(index) {
$(this).on('click','.copy-to-clipboard input', function() {
$(this).focus();
$(this).select();
document.execCommand('copy');
//$(".copied").text("Copied to clipboard").show().fadeOut(1200);
});
});
});
</script>
<?php
}
}
// Basic
add_action('acf/prepare_field/type=text', 'show_field_details', 1);
add_action('acf/prepare_field/type=textarea', 'show_field_details', 1);
add_action('acf/prepare_field/type=number', 'show_field_details', 1);
add_action('acf/prepare_field/type=range', 'show_field_details', 1);
add_action('acf/prepare_field/type=email', 'show_field_details', 1);
add_action('acf/prepare_field/type=url', 'show_field_details', 1);
add_action('acf/prepare_field/type=password', 'show_field_details', 1);
// Content
add_action('acf/prepare_field/type=image', 'show_field_details', 1);
add_action('acf/prepare_field/type=file', 'show_field_details', 1);
add_action('acf/prepare_field/type=wysiwyg', 'show_field_details', 1);
add_action('acf/prepare_field/type=oembed', 'show_field_details', 1);
add_action('acf/prepare_field/type=gallery', 'show_field_details', 1);
// Choice
add_action('acf/prepare_field/type=select', 'show_field_details', 1);
add_action('acf/prepare_field/type=checkbox', 'show_field_details', 1);
add_action('acf/prepare_field/type=radio', 'show_field_details', 1);
add_action('acf/prepare_field/type=button_group', 'show_field_details', 1);
add_action('acf/prepare_field/type=true_false', 'show_field_details', 1);
// Relational
add_action('acf/prepare_field/type=link', 'show_field_details', 1);
add_action('acf/prepare_field/type=post_object', 'show_field_details', 1);
add_action('acf/prepare_field/type=page_link', 'show_field_details', 1);
add_action('acf/prepare_field/type=relationship', 'show_field_details', 1);
add_action('acf/prepare_field/type=taxonomy', 'show_field_details', 1);
add_action('acf/prepare_field/type=user', 'show_field_details', 1);
// jQuery
add_action('acf/prepare_field/type=google_map', 'show_field_details', 1);
add_action('acf/prepare_field/type=date_picker', 'show_field_details', 1);
add_action('acf/prepare_field/type=date_time_picker', 'show_field_details', 1);
add_action('acf/prepare_field/type=time_picker', 'show_field_details', 1);
add_action('acf/prepare_field/type=color_picker', 'show_field_details', 1);
// Layout
//add_action('acf/prepare_field/type=message', 'show_field_details', 1);
add_action('acf/prepare_field/type=accordion', 'show_field_details', 1);
//add_action('acf/prepare_field/type=tab', 'show_field_details', 1);
add_action('acf/prepare_field/type=group', 'show_field_details', 1);
add_action('acf/prepare_field/type=repeater', 'show_field_details', 1);
add_action('acf/prepare_field/type=flexible_content', 'show_field_details', 1);
add_action('acf/prepare_field/type=clone', 'show_field_details', 1);
function show_field_details($field) {
$field['label'] .= '<div class="description copy-to-clipboard" style="margin-bottom: 10px; margin-top: 10px;">
<input readonly="readonly" type="text" value="'.trim($field['_name']).'" style="color: #0c5460;">
</div>';
return $field;
}
add_action('acf/field_group/admin_footer', 'my_acf_field_group_admin_footer');
function my_acf_field_group_admin_footer() { ?>
<script type="text/javascript">
(function( $ ){
$('.description.copy-to-clipboard').remove();
})(jQuery);
</script>
<?php
}
Found some information that may be the culprit:
https://make.wordpress.org/core/2019/09/23/date-time-improvements-wp-5-3/
Thank you! This solution worked great to get my acf custom fields into a product variation, with one exception – one of my fields is a datepicker field. The datepicker script won’t trigger on the field in the product variation, and manually entering a date doesn’t save the data. What am I missing? Thanks.
Just to further update — I will figure this out 😃
@elliot — I think I’ve narrowed the issue down to something to do with Bedrock.
A default install of WordPress with the default theme displays the date correctly from the datepicker field.
I’m now going to install a default version of Bedrock with a default theme and see what this returns.

If it helps you, import this as “something.json” in your ACF and check it out.
[
{
"key": "group_5d75feeccbdc9",
"title": "Spalten",
"fields": [
{
"key": "field_5d725da67101e",
"label": "Spalten",
"name": "columns",
"type": "flexible_content",
"instructions": "",
"required": 0,
"conditional_logic": 0,
"wrapper": {
"width": "",
"class": "",
"id": ""
},
"layouts": {
"layout_5d720da0975d2": {
"key": "layout_5d720da0975d2",
"name": "columns_row_row_h2",
"label": "Headline (H2)",
"display": "block",
"sub_fields": [
{
"key": "field_5d725da671025",
"label": "Text",
"name": "text",
"type": "text",
"instructions": "",
"required": 0,
"conditional_logic": 0,
"wrapper": {
"width": "",
"class": "",
"id": ""
},
"acfe_permissions": "",
"default_value": "",
"placeholder": "",
"prepend": "",
"append": "",
"maxlength": "",
"acfe_validate": false,
"acfe_update": false
}
],
"min": "",
"max": ""
},
"layout_5d720ea2b59b6": {
"key": "layout_5d720ea2b59b6",
"name": "columns_row_row_h3",
"label": "Headline (H3)",
"display": "block",
"sub_fields": [
{
"key": "field_5d725da67102c",
"label": "Text",
"name": "text",
"type": "text",
"instructions": "",
"required": 0,
"conditional_logic": 0,
"wrapper": {
"width": "",
"class": "",
"id": ""
},
"acfe_permissions": "",
"default_value": "",
"placeholder": "",
"prepend": "",
"append": "",
"maxlength": "",
"acfe_validate": false,
"acfe_update": false
}
],
"min": "",
"max": ""
},
"layout_5d6f7653437a2": {
"key": "layout_5d6f7653437a2",
"name": "columns_row_row_intro",
"label": "Einleitung",
"display": "block",
"sub_fields": [
{
"key": "field_5d725da671033",
"label": "Editor",
"name": "columns_row_row_intro_editor",
"type": "wysiwyg",
"instructions": "",
"required": 1,
"conditional_logic": 0,
"wrapper": {
"width": "",
"class": "",
"id": ""
},
"acfe_permissions": "",
"default_value": "",
"tabs": "all",
"toolbar": "full",
"media_upload": 0,
"delay": 0,
"acfe_validate": false,
"acfe_update": false
}
],
"min": "",
"max": ""
},
"577ba52f12d8c": {
"key": "577ba52f12d8c",
"name": "columns_row_row_wysiwyg",
"label": "Editor",
"display": "block",
"sub_fields": [
{
"key": "field_5d725da67103a",
"label": "Editor",
"name": "columns_row_row_wysiwyg_editor",
"type": "wysiwyg",
"instructions": "",
"required": 1,
"conditional_logic": 0,
"wrapper": {
"width": "",
"class": "",
"id": ""
},
"acfe_permissions": "",
"default_value": "",
"tabs": "all",
"toolbar": "full",
"media_upload": 0,
"delay": 0,
"acfe_validate": false,
"acfe_update": false
}
],
"min": "",
"max": ""
},
"layout_5d6f7c304ec2a": {
"key": "layout_5d6f7c304ec2a",
"name": "columns_row_row_card",
"label": "Karte",
"display": "block",
"sub_fields": [
{
"key": "field_5d725da671041",
"label": "Bild",
"name": "columns_row_row_card_img",
"type": "image",
"instructions": "",
"required": 0,
"conditional_logic": 0,
"wrapper": {
"width": "",
"class": "",
"id": ""
},
"acfe_permissions": "",
"return_format": "array",
"preview_size": "thumbnail",
"library": "all",
"min_width": "",
"min_height": "",
"min_size": "",
"max_width": "",
"max_height": "",
"max_size": "",
"mime_types": "",
"acfe_thumbnail": 0,
"acfe_validate": false,
"acfe_update": false
},
{
"key": "field_5d725da671042",
"label": "Header",
"name": "columns_row_row_card_header",
"type": "text",
"instructions": "",
"required": 0,
"conditional_logic": 0,
"wrapper": {
"width": "",
"class": "",
"id": ""
},
"acfe_permissions": "",
"default_value": "",
"placeholder": "",
"prepend": "",
"append": "",
"maxlength": "",
"acfe_validate": false,
"acfe_update": false
},
{
"key": "field_5d725da671043",
"label": "Editor",
"name": "columns_row_row_card_editor",
"type": "wysiwyg",
"instructions": "",
"required": 0,
"conditional_logic": 0,
"wrapper": {
"width": "",
"class": "",
"id": ""
},
"acfe_permissions": "",
"default_value": "",
"tabs": "all",
"toolbar": "full",
"media_upload": 0,
"delay": 0,
"acfe_validate": false,
"acfe_update": false
},
{
"key": "field_5d725da671044",
"label": "Button (Mehr Info)",
"name": "columns_row_row_card_button",
"type": "link",
"instructions": "",
"required": 0,
"conditional_logic": 0,
"wrapper": {
"width": "",
"class": "",
"id": ""
},
"acfe_permissions": "",
"return_format": "array",
"acfe_validate": false,
"acfe_update": false
}
],
"min": "",
"max": ""
},
"layout_5d6f95c598351": {
"key": "layout_5d6f95c598351",
"name": "columns_row_row_feature",
"label": "Feature",
"display": "block",
"sub_fields": [
{
"key": "field_5d725da67104b",
"label": "Bild",
"name": "img",
"type": "image",
"instructions": "",
"required": 0,
"conditional_logic": 0,
"wrapper": {
"width": "",
"class": "",
"id": ""
},
"acfe_permissions": "",
"return_format": "id",
"preview_size": "thumbnail",
"library": "all",
"min_width": "",
"min_height": "",
"min_size": "",
"max_width": "",
"max_height": "",
"max_size": "",
"mime_types": "",
"acfe_thumbnail": 0,
"acfe_validate": false,
"acfe_update": false
},
{
"key": "field_5d725da67104c",
"label": "Headline",
"name": "headline",
"type": "text",
"instructions": "",
"required": 0,
"conditional_logic": 0,
"wrapper": {
"width": "",
"class": "",
"id": ""
},
"acfe_permissions": "",
"default_value": "",
"placeholder": "",
"prepend": "",
"append": "",
"maxlength": "",
"acfe_validate": false,
"acfe_update": false
},
{
"key": "field_5d725da67104d",
"label": "Editor",
"name": "editor",
"type": "wysiwyg",
"instructions": "",
"required": 0,
"conditional_logic": 0,
"wrapper": {
"width": "",
"class": "",
"id": ""
},
"acfe_permissions": "",
"default_value": "",
"tabs": "all",
"toolbar": "full",
"media_upload": 0,
"delay": 0,
"acfe_validate": false,
"acfe_update": false
},
{
"key": "field_5d725da67104e",
"label": "Button (Mehr Info)",
"name": "button",
"type": "link",
"instructions": "",
"required": 0,
"conditional_logic": 0,
"wrapper": {
"width": "",
"class": "",
"id": ""
},
"acfe_permissions": "",
"return_format": "array",
"acfe_validate": false,
"acfe_update": false
},
{
"key": "field_5d725da67104f",
"label": "Optionen",
"name": "",
"type": "accordion",
"instructions": "",
"required": 0,
"conditional_logic": 0,
"wrapper": {
"width": "",
"class": "",
"id": ""
},
"acfe_permissions": "",
"open": 0,
"multi_expand": 0,
"endpoint": 0
},
{
"key": "field_5d725da671050",
"label": "Bild rechts",
"name": "img_right",
"type": "true_false",
"instructions": "",
"required": 0,
"conditional_logic": 0,
"wrapper": {
"width": "",
"class": "",
"id": ""
},
"acfe_permissions": "",
"message": "Bild rechts",
"default_value": 0,
"ui": 0,
"ui_on_text": "",
"ui_off_text": "",
"acfe_validate": false,
"acfe_update": false
}
],
"min": "",
"max": ""
},
"layout_5d7f731463ff4": {
"key": "layout_5d7f731463ff4",
"name": "columns_row_row_b",
"label": "Bild (volle Breite)",
"display": "block",
"sub_fields": [
{
"key": "field_5d7f731463ff5",
"label": "Bild",
"name": "img",
"type": "image",
"instructions": "",
"required": 0,
"conditional_logic": 0,
"wrapper": {
"width": "",
"class": "",
"id": ""
},
"return_format": "array",
"preview_size": "thumbnail",
"library": "all",
"min_width": "",
"min_height": "",
"min_size": "",
"max_width": "",
"max_height": "",
"max_size": "",
"mime_types": ""
}
],
"min": "",
"max": ""
},
"layout_5d7221914e469": {
"key": "layout_5d7221914e469",
"name": "columns_row_row_bt",
"label": "Bild (volle Breite) + Text",
"display": "block",
"sub_fields": [
{
"key": "field_5d725da671057",
"label": "Bild",
"name": "img",
"type": "image",
"instructions": "",
"required": 0,
"conditional_logic": 0,
"wrapper": {
"width": "",
"class": "",
"id": ""
},
"acfe_permissions": "",
"return_format": "array",
"preview_size": "thumbnail",
"library": "all",
"min_width": "",
"min_height": "",
"min_size": "",
"max_width": "",
"max_height": "",
"max_size": "",
"mime_types": "",
"acfe_thumbnail": 0,
"acfe_validate": false,
"acfe_update": false
},
{
"key": "field_5d725da671058",
"label": "Editor",
"name": "editor",
"type": "wysiwyg",
"instructions": "",
"required": 0,
"conditional_logic": 0,
"wrapper": {
"width": "",
"class": "",
"id": ""
},
"acfe_permissions": "",
"default_value": "",
"tabs": "all",
"toolbar": "full",
"media_upload": 0,
"delay": 0,
"acfe_validate": false,
"acfe_update": false
}
],
"min": "",
"max": ""
},
"layout_5d024db252b54": {
"key": "layout_5d024db252b54",
"name": "columns_row_row_trenner",
"label": "Trenner",
"display": "block",
"sub_fields": [
{
"key": "field_5d725da671059",
"label": "Info",
"name": "",
"type": "message",
"instructions": "",
"required": 0,
"conditional_logic": 0,
"wrapper": {
"width": "",
"class": "",
"id": ""
},
"acfe_permissions": "",
"message": "Ein Trennelement das die Reihe mit Spalten davor beendet (erzwungener Umbruch).",
"new_lines": "wpautop",
"esc_html": 0
},
{
"key": "field_5d725da67105a",
"label": "Optionen",
"name": "",
"type": "accordion",
"instructions": "",
"required": 0,
"conditional_logic": 0,
"wrapper": {
"width": "",
"class": "",
"id": ""
},
"acfe_permissions": "",
"open": 0,
"multi_expand": 0,
"endpoint": 0
},
{
"key": "field_5d725da67105b",
"label": "Trenner Design",
"name": "_inse_trenner_design",
"type": "radio",
"instructions": "",
"required": 0,
"conditional_logic": 0,
"wrapper": {
"width": "",
"class": "",
"id": ""
},
"acfe_permissions": "",
"choices": {
"stroke": "Linie",
"ghost": "Unsichtbar"
},
"allow_null": 0,
"other_choice": 0,
"save_other_choice": 0,
"default_value": "",
"layout": "vertical",
"return_format": "value",
"acfe_validate": false,
"acfe_update": false
},
{
"key": "field_5d725da67105c",
"label": "Trenner Design Optionen",
"name": "_inse_trenner_design_options_1_gr",
"type": "group",
"instructions": "",
"required": 0,
"conditional_logic": [
[
{
"field": "field_5d725da67105b",
"operator": "==",
"value": "stroke"
}
]
],
"wrapper": {
"width": "",
"class": "",
"id": ""
},
"acfe_permissions": "",
"layout": "block",
"sub_fields": [
{
"key": "field_5d725da67105d",
"label": "Farbe",
"name": "_color",
"type": "color_picker",
"instructions": "",
"required": 0,
"conditional_logic": 0,
"wrapper": {
"width": "",
"class": "",
"id": ""
},
"acfe_permissions": "",
"default_value": "#fff",
"acfe_validate": false,
"acfe_update": false
},
{
"key": "field_5d725da67105e",
"label": "Stärke",
"name": "_width",
"type": "number",
"instructions": "",
"required": 0,
"conditional_logic": 0,
"wrapper": {
"width": "",
"class": "",
"id": ""
},
"acfe_permissions": "",
"default_value": 3,
"placeholder": 3,
"prepend": "",
"append": "Pixel",
"min": 1,
"max": "",
"step": "",
"acfe_validate": false,
"acfe_update": false
}
]
}
],
"min": "",
"max": ""
},
"layout_5d70cec989566": {
"key": "layout_5d70cec989566",
"name": "columns_row_row_accordion",
"label": "Accordion",
"display": "block",
"sub_fields": [
{
"key": "field_5d725da671065",
"label": "Accordion Zeile",
"name": "accordion_zeile",
"type": "repeater",
"instructions": "",
"required": 0,
"conditional_logic": 0,
"wrapper": {
"width": "",
"class": "",
"id": ""
},
"acfe_permissions": "",
"collapsed": "",
"min": 0,
"max": 0,
"layout": "block",
"button_label": "Accordion Zeile hinzufügen",
"sub_fields": [
{
"key": "field_5d725da671066",
"label": "Titel",
"name": "accordion_titel",
"type": "text",
"instructions": "",
"required": 0,
"conditional_logic": 0,
"wrapper": {
"width": "",
"class": "",
"id": ""
},
"acfe_permissions": "",
"default_value": "",
"placeholder": "",
"prepend": "",
"append": "",
"maxlength": "",
"acfe_validate": false,
"acfe_update": false
},
{
"key": "field_5d725da671067",
"label": "Accordion Text",
"name": "accordion_text",
"type": "wysiwyg",
"instructions": "",
"required": 0,
"conditional_logic": 0,
"wrapper": {
"width": "",
"class": "",
"id": ""
},
"acfe_permissions": "",
"default_value": "",
"tabs": "all",
"toolbar": "basic",
"media_upload": 0,
"delay": 0,
"acfe_validate": false,
"acfe_update": false
}
]
}
],
"min": "",
"max": ""
},
"layout_5d7114e0e3584": {
"key": "layout_5d7114e0e3584",
"name": "columns_row_row_downloads",
"label": "Downloads",
"display": "block",
"sub_fields": [
{
"key": "field_5d725da67106e",
"label": "Downloads",
"name": "_listdl",
"type": "repeater",
"instructions": "",
"required": 0,
"conditional_logic": false,
"wrapper": {
"width": "",
"class": "",
"id": ""
},
"acfe_permissions": "",
"min": 0,
"max": 0,
"layout": "table",
"button_label": "",
"collapsed": "",
"sub_fields": [
{
"key": "field_5d725da67106f",
"label": "Download",
"name": "_singledl",
"type": "file",
"instructions": "",
"required": 0,
"conditional_logic": [
[
{
"field": "field_5d725da671070",
"operator": "!=",
"value": "1"
}
]
],
"wrapper": {
"width": "",
"class": "",
"id": ""
},
"acfe_permissions": "",
"return_format": "id",
"library": "all",
"min_size": "",
"max_size": "",
"mime_types": "",
"acfe_validate": false,
"acfe_update": false
},
{
"key": "field_5d725da671070",
"label": "Externer Download",
"name": "_singledl_extern_choice",
"type": "true_false",
"instructions": "",
"required": 0,
"conditional_logic": 0,
"wrapper": {
"width": "20",
"class": "",
"id": ""
},
"acfe_permissions": "",
"message": "Externe Datei",
"default_value": 0,
"ui": 0,
"ui_on_text": "",
"ui_off_text": "",
"acfe_validate": false,
"acfe_update": false
},
{
"key": "field_5d725da671071",
"label": "Download extern",
"name": "_singledl_extern",
"type": "text",
"instructions": "",
"required": 0,
"conditional_logic": [
[
{
"field": "field_5d725da671070",
"operator": "==",
"value": "1"
}
]
],
"wrapper": {
"width": "",
"class": "",
"id": ""
},
"acfe_permissions": "",
"default_value": "",
"placeholder": "https:\/\/www. ...",
"prepend": "",
"append": "",
"maxlength": "",
"acfe_validate": false,
"acfe_update": false
}
]
}
],
"min": "",
"max": ""
},
"layout_5d7627e37a23f": {
"key": "layout_5d7627e37a23f",
"name": "columns_row_row_video",
"label": "Video",
"display": "block",
"sub_fields": [
{
"key": "field_5d7627fd7a240",
"label": "Video",
"name": "video",
"type": "oembed",
"instructions": "Geben Sie in dem Feld \"URL eingeben\" den Link zum Video ein. Beispiele:<br \/>\r\nhttps:\/\/www.youtube.com\/watch?v=jNQXAC9IVRw<br \/>\r\nhttps:\/\/vimeo.com\/channels\/staffpicks\/98741946",
"required": 0,
"conditional_logic": 0,
"wrapper": {
"width": "",
"class": "",
"id": ""
},
"width": "",
"height": ""
}
],
"min": "",
"max": ""
},
"layout_5d762bb5c8563": {
"key": "layout_5d762bb5c8563",
"name": "columns_row_row_personen",
"label": "Personen",
"display": "block",
"sub_fields": [
{
"key": "field_5d762c3ac8564",
"label": "Person",
"name": "person",
"type": "relationship",
"instructions": "",
"required": 0,
"conditional_logic": 0,
"wrapper": {
"width": "",
"class": "",
"id": ""
},
"post_type": [
"person"
],
"taxonomy": "",
"filters": [
"search"
],
"elements": [
"featured_image"
],
"min": "",
"max": "",
"return_format": "object"
},
{
"key": "field_5d7631151dde7",
"label": "Details",
"name": "_ausblenden",
"type": "checkbox",
"instructions": "Entfernen Sie den Haken der Felder welche nicht auf der Website angezeigt werden sollen (gilt dann nur für diese Seite).",
"required": 0,
"conditional_logic": 0,
"wrapper": {
"width": "",
"class": "",
"id": ""
},
"choices": {
"pos": "Position",
"email": "E-Mail",
"telefon": "Telefon",
"address": "Adresse",
"foto": "Foto"
},
"allow_custom": 0,
"default_value": [
"pos",
"email",
"telefon",
"address",
"foto"
],
"layout": "horizontal",
"toggle": 0,
"return_format": "value",
"save_custom": 0
}
],
"min": "",
"max": ""
},
"layout_5d765d2193ab3": {
"key": "layout_5d765d2193ab3",
"name": "columns_row_row_prozentanzeige",
"label": "Prozentanzeige",
"display": "block",
"sub_fields": [
{
"key": "field_5d765ef920e87",
"label": "Prozent Balken",
"name": "prozent_balken",
"type": "repeater",
"instructions": "",
"required": 0,
"conditional_logic": 0,
"wrapper": {
"width": "",
"class": "",
"id": ""
},
"collapsed": "",
"min": 0,
"max": 0,
"layout": "table",
"button_label": "",
"sub_fields": [
{
"key": "field_5d765f1020e89",
"label": "Prozent",
"name": "prozent",
"type": "text",
"instructions": "",
"required": 0,
"conditional_logic": 0,
"wrapper": {
"width": "20",
"class": "",
"id": ""
},
"default_value": "",
"placeholder": "",
"prepend": "",
"append": "%",
"maxlength": ""
},
{
"key": "field_5d765f0520e88",
"label": "Text",
"name": "text",
"type": "text",
"instructions": "",
"required": 0,
"conditional_logic": 0,
"wrapper": {
"width": "80",
"class": "",
"id": ""
},
"default_value": "",
"placeholder": "",
"prepend": "",
"append": "",
"maxlength": ""
}
]
}
],
"min": "",
"max": ""
},
"layout_5d766e2e96670": {
"key": "layout_5d766e2e96670",
"name": "columns_row_row_seniorenzentrum",
"label": "Einrichtung",
"display": "block",
"sub_fields": [
{
"key": "field_5d766f4996671",
"label": "Einrichtung",
"name": "einrichtung",
"type": "relationship",
"instructions": "",
"required": 0,
"conditional_logic": 0,
"wrapper": {
"width": "",
"class": "",
"id": ""
},
"post_type": [
"einrichtung"
],
"taxonomy": "",
"filters": [
"search"
],
"elements": [
"featured_image"
],
"min": "",
"max": "",
"return_format": "object"
}
],
"min": "",
"max": ""
},
"layout_5d9df2c47b33a": {
"key": "layout_5d9df2c47b33a",
"name": "columns_row_row_jobsfeed",
"label": "Stellenangebote (Feed)",
"display": "block",
"sub_fields": [
{
"key": "field_5d9df2dc7b33b",
"label": "Info",
"name": "",
"type": "message",
"instructions": "",
"required": 0,
"conditional_logic": 0,
"wrapper": {
"width": "",
"class": "",
"id": ""
},
"message": "Aktuelle Stellenangebote von \"<strong>https:\/\/www.awo-stellenboerse.de<\/strong>\/stellenboerse-hamburg-seniorenwohnen.json\".",
"new_lines": "wpautop",
"esc_html": 0
}
],
"min": "",
"max": ""
}
},
"button_label": "Spalte hinzufügen",
"min": "",
"max": ""
}
],
"location": [
[
{
"param": "post_template",
"operator": "==",
"value": "tpl-sidebar_left.php"
}
],
[
{
"param": "post_template",
"operator": "==",
"value": "tpl-fullwidth_m.php"
}
]
],
"menu_order": 0,
"position": "normal",
"style": "default",
"label_placement": "top",
"instruction_placement": "label",
"hide_on_screen": "",
"active": true,
"description": ""
}
]

Actually, neither did I, after this I went and updated a site that was going to break soon. I have something similar that has month, day and time (date/time picker). I didn’t account for changing years either 😛

I looked into the code, the date field does not work with setting $field['default_value']. You need to use this https://www.advancedcustomfields.com/resources/javascript-api/#filters-date_picker_args
I do not know the correct code you need to use here to set the date, you will need to look at the jquery date picker docs here https://api.jqueryui.com/datepicker/
I created the simplest possible Dev Studio screen. A text input only. I then added the javascript items for JQuery and datepicker TellDunkin.
The answer from @questioner is working.
Here is a picture of how to get the key of the date picker.

I implemented it on this website and it is working
https://mipon.org/events/
Figured it out!
There’s a section of assets/js/acf_input.js that interfaces with the WordPress media library. Unfortunately it specifically targets the image field type. I ended up copying a big lump of javascript and changing the type identifier… here’s the code that I copied, notice that I just changed the ‘type’ parameter and it all worked.
I’m sure there must be an easier way to reuse this… I assume some field authors have figured out a way to include a media picker in a more subtle way. I reckon this page would be helpful if I had time to investigate
(function($, undefined){
var Field = acf.Field.extend({
type: 'my_new_field',
$control: function(){
return this.$('.acf-image-uploader');
},
$input: function(){
return this.$('input[type="hidden"]');
},
events: {
'click a[data-name="add"]': 'onClickAdd',
'click a[data-name="edit"]': 'onClickEdit',
'click a[data-name="remove"]': 'onClickRemove',
'change input[type="file"]': 'onChange'
},
initialize: function(){
// add attribute to form
if( this.get('uploader') === 'basic' ) {
this.$el.closest('form').attr('enctype', 'multipart/form-data');
}
},
validateAttachment: function( attachment ){
// defaults
attachment = attachment || {};
// WP attachment
if( attachment.id !== undefined ) {
attachment = attachment.attributes;
}
// args
attachment = acf.parseArgs(attachment, {
url: '',
alt: '',
title: '',
caption: '',
description: '',
width: 0,
height: 0
});
// preview size
var url = acf.isget(attachment, 'sizes', this.get('preview_size'), 'url');
if( url !== null ) {
attachment.url = url;
}
// return
return attachment;
},
render: function( attachment ){
// vars
attachment = this.validateAttachment( attachment );
// update image
this.$('img').attr({
src: attachment.url,
alt: attachment.alt,
title: attachment.title
});
// vars
var val = attachment.id || '';
// update val
this.val( val );
// update class
if( val ) {
this.$control().addClass('has-value');
} else {
this.$control().removeClass('has-value');
}
},
// create a new repeater row and render value
append: function( attachment, parent ){
// create function to find next available field within parent
var getNext = function( field, parent ){
// find existing file fields within parent
var fields = acf.getFields({
key: field.get('key'),
parent: parent.$el
});
// find the first field with no value
for( var i = 0; i < fields.length; i++ ) {
if( !fields[i].val() ) {
return fields[i];
}
}
// return
return false;
}
// find existing file fields within parent
var field = getNext( this, parent );
// add new row if no available field
if( !field ) {
parent.$('.acf-button:last').trigger('click');
field = getNext( this, parent );
}
// render
if( field ) {
field.render( attachment );
}
},
selectAttachment: function(){
// vars
var parent = this.parent();
var multiple = (parent && parent.get('type') === 'repeater');
// new frame
var frame = acf.newMediaPopup({
mode: 'select',
type: 'image',
title: acf.__('Select Image'),
field: this.get('key'),
multiple: multiple,
library: this.get('library'),
allowedTypes: this.get('mime_types'),
select: $.proxy(function( attachment, i ) {
if( i > 0 ) {
this.append( attachment, parent );
} else {
this.render( attachment );
}
}, this)
});
},
editAttachment: function(){
// vars
var val = this.val();
// bail early if no val
if( !val ) return;
// popup
var frame = acf.newMediaPopup({
mode: 'edit',
title: acf.__('Edit Image'),
button: acf.__('Update Image'),
attachment: val,
field: this.get('key'),
select: $.proxy(function( attachment, i ) {
this.render( attachment );
}, this)
});
},
removeAttachment: function(){
this.render( false );
},
onClickAdd: function( e, $el ){
this.selectAttachment();
},
onClickEdit: function( e, $el ){
this.editAttachment();
},
onClickRemove: function( e, $el ){
this.removeAttachment();
},
onChange: function( e, $el ){
var $hiddenInput = this.$input();
acf.getFileInputData($el, function( data ){
$hiddenInput.val( $.param(data) );
});
}
});
acf.registerFieldType( Field );
})(jQuery);
To hide the seconds input, use the following:
(function() {
acf.add_filter('date_time_picker_args', function( args, field ){
args.showSecond = false;
return args;
});
})();
There are also options for ‘showHours’, ‘showMinutes’, ‘showMillisec’, ‘showMicrosec’ and ‘showTimezone’.
See the options tab in the documentation
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.