acf_field_checkbox::render_field()publicACF 3.6

Create the HTML interface for your field

{} Это метод класса: acf_field_checkbox{}

Хуков нет.

Возвращает

null. Ничего.

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

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

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

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

Код acf_field_checkbox::render_field() ACF 5.10.2

function render_field( $field ) {

	// reset vars
	$this->_values      = array();
	$this->_all_checked = true;

	// ensure array
	$field['value']   = acf_get_array( $field['value'] );
	$field['choices'] = acf_get_array( $field['choices'] );

	// hiden input
	acf_hidden_input( array( 'name' => $field['name'] ) );

	// vars
	$li = '';
	$ul = array(
		'class' => 'acf-checkbox-list',
	);

	// append to class
	$ul['class'] .= ' ' . ( $field['layout'] == 'horizontal' ? 'acf-hl' : 'acf-bl' );
	$ul['class'] .= ' ' . $field['class'];

	// checkbox saves an array
	$field['name'] .= '[]';

	// choices
	if ( ! empty( $field['choices'] ) ) {

		// choices
		$li .= $this->render_field_choices( $field );

		// toggle
		if ( $field['toggle'] ) {
			$li = $this->render_field_toggle( $field ) . $li;
		}
	}

	// custom
	if ( $field['allow_custom'] ) {
		$li .= $this->render_field_custom( $field );
	}

	// return
	echo '<ul ' . acf_esc_attr( $ul ) . '>' . "\n" . $li . '</ul>' . "\n";

}