acf_field_date_picker::render_field()publicACF 3.6

Create the HTML interface for your field

Метод класса: acf_field_date_picker{}

Хуков нет.

Возвращает

null. Ничего (null).

Использование

$acf_field_date_picker = new acf_field_date_picker();
$acf_field_date_picker->render_field( $field );
$field (обязательный)
-

Список изменений

С версии 3.6 Введена.

Код acf_field_date_picker::render_field() ACF 6.0.4

<?php
function render_field( $field ) {

	// vars
	$hidden_value  = '';
	$display_value = '';

	// format value
	if ( $field['value'] ) {
		$hidden_value  = acf_format_date( $field['value'], 'Ymd' );
		$display_value = acf_format_date( $field['value'], $field['display_format'] );
	}

	// elements
	$div          = array(
		'class'            => 'acf-date-picker acf-input-wrap',
		'data-date_format' => acf_convert_date_to_js( $field['display_format'] ),
		'data-first_day'   => $field['first_day'],
	);
	$hidden_input = array(
		'id'    => $field['id'],
		'name'  => $field['name'],
		'value' => $hidden_value,
	);
	$text_input   = array(
		'class' => $field['class'] . ' input',
		'value' => $display_value,
	);

	// special attributes
	foreach ( array( 'readonly', 'disabled' ) as $k ) {
		if ( ! empty( $field[ $k ] ) ) {
			$hidden_input[ $k ] = $k;
			$text_input[ $k ]   = $k;
		}
	}

	// save_format - compatibility with ACF < 5.0.0
	if ( ! empty( $field['save_format'] ) ) {

		// add custom JS save format
		$div['data-save_format'] = $field['save_format'];

		// revert hidden input value to raw DB value
		$hidden_input['value'] = $field['value'];

		// remove formatted value (will do this via JS)
		$text_input['value'] = '';
	}

	// html
	?>
<div <?php echo acf_esc_attrs( $div ); ?>>
	<?php acf_hidden_input( $hidden_input ); ?>
	<?php acf_text_input( $text_input ); ?>
</div>
	<?php
}