acf_field_checkbox::get_rest_schema │ public │ ACF 1.0

Return the schema array for the REST API.

Method of the class: acf_field_checkbox{}

No Hooks.

Returns

array.

Usage

$acf_field_checkbox = new acf_field_checkbox();
$acf_field_checkbox->get_rest_schema( $field );
$field(array) (required)
.

acf_field_checkbox::get_rest_schema() code ACF 6.8.8

public function get_rest_schema( array $field ) {
	$schema = array(
		'type'     => array( 'integer', 'string', 'array', 'null' ),
		'required' => isset( $field['required'] ) && $field['required'],
		'items'    => array(
			'type' => array( 'string', 'integer' ),
		),
	);

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

	// If we allow custom values, nothing else to do here.
	if ( ! empty( $field['allow_custom'] ) ) {
		return $schema;
	}

	$schema['items']['enum'] = acf_get_field_type( 'select' )->format_rest_choices( $field['choices'] );

	return $schema;
}