WP_REST_View_Config_Controller::get_form_field_schema(): array

In this article

Returns the schema for a form field item (string or object).

Return

array Schema for a form field.

Source

protected function get_form_field_schema() {
	return array(
		'oneOf' => array(
			array( 'type' => 'string' ),
			array(
				'type'       => 'object',
				'properties' => array(
					'id'          => array(
						'type' => 'string',
					),
					'label'       => array(
						'type' => 'string',
					),
					'description' => array(
						'type' => 'string',
					),
					'layout'      => $this->get_form_layout_schema(),
					'children'    => array(
						'type'  => 'array',
						'items' => array(
							'oneOf' => array(
								array( 'type' => 'string' ),
								// This object can have the shape of a form field itself,
								// allowing for recursive nesting of form fields.
								// There's no easy way to codify this recursion via the JSON Schema draft-04
								// supported by the REST API.
								array( 'type' => 'object' ),
							),
						),
					),
				),
			),
		),
	);
}

Changelog

VersionDescription
7.1.0Introduced.

User Contributed Notes

You must log in before being able to contribute a note or feedback.