acf_field_select::get_rest_schemapublicACF 1.0

Return the schema array for the REST API.

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

Хуков нет.

Возвращает

Массив.

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

$acf_field_select = new acf_field_select();
$acf_field_select->get_rest_schema( $field );
$field(массив) (обязательный)
The main field array.

Код acf_field_select::get_rest_schema() ACF 6.4.2

public function get_rest_schema( array $field ) {
	$schema = array(
		'type'     => array( 'string', 'array', 'int', 'null' ),
		'required' => ! empty( $field['required'] ),
		'items'    => array(
			'type' => array( 'string', 'int' ),
			'enum' => $this->format_rest_choices( $field['choices'] ),
		),
	);

	if ( empty( $field['allow_null'] ) ) {
		$schema['minItems'] = 1;
	}

	if ( empty( $field['multiple'] ) ) {
		$schema['maxItems'] = 1;
	}

	if ( isset( $field['default_value'] ) && '' !== $field['default_value'] ) {
		$schema['default'] = $field['default_value'];
	}

	return $schema;
}