WP_REST_View_Config_Controller::get_form_field_schema
Returns the schema for a form field item (string or object).
Method of the class: WP_REST_View_Config_Controller{}
No Hooks.
Returns
array. Schema for a form field.
Usage
// protected - for code of main (parent) or child class $result = $this->get_form_field_schema();
Changelog
| Since 7.1.0 | Introduced. |
WP_REST_View_Config_Controller::get_form_field_schema() WP REST View Config Controller::get form field schema code WP 7.1
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' ),
),
),
),
),
),
),
);
}