Adds a field to the edit page.
Description
See also
Parameters
- $id
-
(string) (Required) Field identifier.
- $type
-
(string) (Required) Identifier of the type.
- $args
-
(array) (Optional) Field arguments. See the field class constructor for further arguments.
- 'tab'
(string) Tab identifier this field belongs to. - 'label'
(string) Field label. - 'description'
(string) Field description. - 'default'
(mixed) Default value for the field. Default null. - 'input_classes'
(array) Array of CSS classes for the field input. - 'label_classes'
(array) Array of CSS classes for the field label. - 'input_attrs'
(array) Array of additional input attributes as$key => $value
pairs.
Default value: array()
- 'tab'
Source
File: src/db-objects/forms/form-edit-page-handler.php
public function add_field( $id, $type, $args = array() ) { if ( isset( $args['tab'] ) ) { $args['section'] = $args['tab']; unset( $args['tab'] ); } if ( ! isset( $args['section'] ) ) { return; } if ( ! isset( $this->tabs[ $args['section'] ] ) ) { return; } if ( ! isset( $this->meta_boxes[ $this->tabs[ $args['section'] ]['meta_box'] ] ) ) { return; } $meta_box_args = $this->meta_boxes[ $this->tabs[ $args['section'] ]['meta_box'] ]; $meta_box_args['field_manager']->add( $id, $type, $args ); }
Changelog
Version | Description |
---|---|
1.0.0 | Introduced. |