Class AdminPageFramework_Controller_Form
Provides public methods to add form elements.
Package: AdminPageFramework\Factory\AdminPage
Since: 2.0.0
Since: 3.3.1 Changed the name from
AdminPageFramework_Setting
.Since: 3.6.3 Changed the name from
AdminPageFramework_Form_Controller
.Extends: AdminPageFramework_View_Form
Located at factory/admin_page/AdminPageFramework_Controller_Form.php
Methods summary
public
|
#
addSettingSections( )
Adds sections. It inserts the given section definition arrays into the class property and later they are parsed when sections are registered. The section definition array have required keys. Refer to the parameter section of this method. Example$this->addSettingSections( array( 'section_id' => 'text_fields', 'title' => __( 'Text Fields', 'your-text-domain' ), 'description' => __( 'These are text type fields.', 'your-text-domain' ), ), array( 'section_id' => 'selectors', 'title' => __( 'Selectors', 'your-text-domain' ), 'description' => __( 'These are selector type options such as dropdown lists, radio buttons, and checkboxes', 'your-text-domain' ), ) ); Example$this->addSettingSections( array( 'section_id' => 'text_fields', 'page_slug' => 'first_page', 'tab_slug' => 'textfields', 'title' => 'Text Fields', 'description' => 'These are text type fields.', 'order' => 10, ), array( 'section_id' => 'selectors', 'page_slug' => 'first_page', 'tab_slug' => 'selectors', 'title' => 'Selectors', 'description' => 'These are selector type options such as dropdown lists, radio buttons, and checkboxes', ) ); Since
2.0.0
3.0.0 Changed the scope to public from protected. 3.5.3 Removed the parameter declarations as they are caught with the func_get_args(). Remark
Accepts variadic parameters; the number of accepted parameters are not limited
to three.
The actual registration will be performed in the _replyToRegisterSettings() method with the admin_menu hook. The target section tab slug and the target tab slug will be reset once the method returns. Overrides |
public
|
#
addSettingSection( array|string $asSection )
A singular form of the adSettingSections() method which takes only a single parameter. This is useful when adding section arrays in loops. Parameters
Since
2.1.2
3.0.0 Changed the scope to public from protected. Overrides |
public
|
#
removeSettingSections( )
Removes the given section(s) by section ID. This accesses the property storing the added section arrays and removes the specified ones. Example$this->removeSettingSections( 'text_fields', 'selectors', 'another_section', 'yet_another_section' ); Since
2.0.0
3.0.0 Changed the scope to public from protected. 3.5.3 Removed the parameter declarations as they are caught with the func_get_args(). Remark
Accepts variadic parameters; the number of accepted parameters are not limited
to three.
|
public
|
#
addSettingFields( )
Adds form fields. It inserts the given field definition arrays into the class property and later they are parsed when fields are registered. The field definition array requires specific keys. Refer to the parameter section of this method. Example$this->addSettingFields( array( 'field_id' => 'text', 'section_id' => 'text_fields', 'title' => __( 'Text', 'my-text-domain' ), 'description' => __( 'Type something here.', 'my-text-domain' ), 'type' => 'text', 'order' => 1, 'default' => 123456, ), array( 'field_id' => 'text_multiple', 'section_id' => 'text_fields', 'title' => __( 'Multiple Text Fields', 'my-text-domain' ), 'description' => __( 'These are multiple text fields.', 'my-text-domain' ), 'type' => 'text', 'order' => 2, 'default' => __( 'Hello World', 'my-text-domain' ), 'label' => __( 'First Item', 'my-text-domain' ), 'attributes' => array( 'size' => 30 ), array( 'label' => __( 'Second Item', 'my-text-domain' ), 'default' => __( 'Foo bar', 'my-text-domain' ), 'attributes' => array( 'size' => 60, ), ), array( 'label' => __( 'Third Item', 'my-text-domain' ), 'default' => __( 'Yes, we can.', 'my-text-domain' ), 'attributes' => array( 'size' => 90, ), ), ) ); Since
2.0.0
3.0.0 Changed the scope to public from protected. 3.5.3 Removed the parameter declarations as they are caught with the func_get_args(). Remark
Accepts variadic parameters; the number of accepted parameters are not limited
to three.
The actual registration will be performed in the _replyToRegisterSettings() method with the admin_menu hook. Overrides |
public
|
#
addSettingField( array|string $asField )
Adds the given field array items into the field array property. Identical to the Parameters
Since
2.1.2
3.0.0 Changed the scope to public from protected. Overrides |
public
|
#
removeSettingFields( string $sFieldID1, string $sFieldID2 = null, string $_and_more = null )
Removes the given field(s) by field ID. This accesses the property storing the added field arrays and removes the specified ones. Example$this->removeSettingFields( 'fieldID_A', 'fieldID_B', 'fieldID_C', 'fieldID_D' ); Parameters
Since
2.0.0
3.0.0 Changed the scope to public from protected. Remark
Accepts variadic parameters; the number of accepted parameters are not limited
to three.
|
public
|
#
getValue( )
Retrieves the specified field value stored in the options by field ID. Example$this->addSettingFields( 'number_section', // section id array( 'field_id' => 'preset_field', 'title' => __( 'Preset', 'admin-page-framework-demo' ), 'type' => 'number', ), array( 'field_id' => 'value_based_on_preset', 'title' => __( 'Value Based on Preset', 'admin-page-framework-demo' ), 'type' => 'number', 'default' => 10 + ( int ) $this->getValue( 'number_section', // section id 'preset_field' // field id ), ), ); Since
3.3.0
3.3.5 Made it respect last input arrays. 3.5.3 When a parameter is not set, it returns the entire options. |