APF_Demo_BuiltinFieldTypes_Selector_Select::__construct PHP Method

__construct() public method

Sets up a form section.
public __construct ( $oFactory )
    public function __construct($oFactory)
    {
        // Section
        $oFactory->addSettingSections($this->sPageSlug, array('section_id' => $this->sSectionID, 'tab_slug' => $this->sTabSlug, 'title' => __('Drop-down Lists', 'admin-page-framework-loader'), 'tip' => __('These are drop-down (pull-down) lists.', 'admin-page-framework-loader')));
        /*
         * Selector type fields - dropdown (pulldown) list, checkbox, radio buttons, size selector
         */
        $oFactory->addSettingFields($this->sSectionID, array('field_id' => 'select', 'title' => __('Dropdown List', 'admin-page-framework-loader'), 'type' => 'select', 'help' => __('This is the <em>select</em> field type.', 'admin-page-framework-loader'), 'default' => 2, 'label' => array(0 => __('Red', 'admin-page-framework-loader'), 1 => __('Blue', 'admin-page-framework-loader'), 2 => __('Yellow', 'admin-page-framework-loader'), 3 => __('Orange', 'admin-page-framework-loader')), 'tip' => __('The key of the array of the <code>label</code> argument serves as the value of the option tag which will be sent to the form and saved in the database.', 'admin-page-framework-loader') . ' ' . __('So when you specify the default value with the <code>default</code> or <code>value</code> argument, specify the <em>KEY</em>.', 'admin-page-framework-loader'), 'description' => array("<pre class='field-argument-example'>" . $oFactory->oWPRMParser->getSyntaxHighlightedPHPCode(<<<EOD
array(
    'type'          => 'select',
    'default'       => 2, // the index key of the label array
    'label'         => array( 
        0 => __( 'Red', 'admin-page-framework-loader' ),
        1 => __( 'Blue', 'admin-page-framework-loader' ),
        2 => __( 'Yellow', 'admin-page-framework-loader' ),
        3 => __( 'Orange', 'admin-page-framework-loader' ),
    ),
)
EOD
) . "</pre>")), array('field_id' => 'select_multiple_options', 'title' => __('Multiple', 'admin-page-framework-loader'), 'help' => __('This is the <em>select</em> field type with multiple elements.', 'admin-page-framework'), 'type' => 'select', 'is_multiple' => true, 'default' => array(3, 4), 'label' => array('January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'November', 'October', 'December'), 'tip' => __('Use <code>is_multiple</code> argument to enable multiple selections.'), 'attributes' => array('select' => array('size' => 10)), 'description' => array("<pre class='field-argument-example'>" . $oFactory->oWPRMParser->getSyntaxHighlightedPHPCode(<<<EOD
array(
    'type'          => 'select',
    'is_multiple'   => true,
    'default'       => array( 3, 4 ), // note that PHP array indices are zero-base
    'label'         => array( 'January', 'February', 'March', 
        'April', 'May', 'June', 'July', 
        'August', 'September', 'November', 
        'October', 'December' 
    ),    
)
EOD
) . "</pre>")), array('field_id' => 'select_multiple_groups', 'title' => __('Grouping', 'admin-page-framework-loader'), 'type' => 'select', 'default' => 'b', 'label' => array('alphabets' => array('a' => 'a', 'b' => 'b', 'c' => 'c'), 'numbers' => array(0 => '0', 1 => '1', 2 => '2')), 'attributes' => array('select' => array('style' => "width: 200px;"), 'option' => array(1 => array('disabled' => 'disabled', 'style' => 'background-color: #ECECEC; color: #888;')), 'optgroup' => array('style' => 'background-color: #DDD')), 'tip' => array(__('To create grouped options, pass arrays with the key of the group label and pass the options as an array inside them.', 'admin-page-framework-loader'), __('To style the pulldown (dropdown) list, use the <code>attributes</code> argument. For the <code>select</code> field type, it has three major keys, <code>select</code>, <code>option</code>, and <code>optgroup</code>, representing the tag names.', 'admin-page-framework-loader')), 'description' => array("<pre class='field-argument-example'>" . $oFactory->oWPRMParser->getSyntaxHighlightedPHPCode(<<<EOD
array(
    'type'          => 'select',
    'default'       => 'b',
    'label'         => array(     
        'alphabets' => array(   
            'a' => 'a',     
            'b' => 'b', 
            'c' => 'c',
        ),
        'numbers' => array( 
            0 => '0',
            1 => '1',
            2 => '2', 
        ),
    ),
)
EOD
) . "</pre>")), array('field_id' => 'select_multiple_fields', 'title' => __('Multiple', 'admin-page-framework-loader'), 'tip' => __('These are multiple sets of drop down list using sub fields.', 'admin-page-framework-loader'), 'type' => 'select', 'label' => array('dark', 'light'), 'default' => 1, 'attributes' => array('field' => array('style' => 'display: inline; clear: none')), array('label' => array('river', 'mountain', 'sky'), 'default' => 2), array('label' => array('Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday', 'Sunday'), 'default' => array(3, 4), 'attributes' => array('select' => array('size' => 5, 'multiple' => 'multiple'))), 'description' => array("<pre class='field-argument-example'>" . $oFactory->oWPRMParser->getSyntaxHighlightedPHPCode(<<<EOD
array(
    'type'          => 'select',
    'label'         => array( 'dark', 'light' ),
    'default'       => 1,
    'attributes'    => array(    
        'field'     => array(
            'style' => 'display: inline; clear: none',
        ),
    ),
    array(
        'label'     => array( 'river', 'mountain', 'sky', ),
        'default'   => 2,
    ),
    array(
        'label'         => array( 
            'Monday', 'Tuesday', 'Wednesday', 
            'Thursday', 'Friday', 'Saturday', 'Sunday' 
        ),
        'default'       => array( 3, 4 ),
        'attributes'    => array(
            'select' => array(
                'size' => 5,
                'multiple' => 'multiple', 
            ),
        )     
    ),
)
EOD
) . "</pre>")), array('field_id' => 'select_repeatable', 'title' => __('Repeatable', 'admin-page-framework-loader'), 'type' => 'select', 'repeatable' => true, 'tip' => __('To enable repeatable fields, pass <code>true</code> to the <code>repeatable</code> argument.', 'admin-page-framework-loader'), 'default' => 'y', 'label' => array('x' => 'X', 'y' => 'Y', 'z' => 'Z'), 'description' => array("<pre class='field-argument-example'>" . $oFactory->oWPRMParser->getSyntaxHighlightedPHPCode(<<<EOD
array(
    'type'          => 'select',
    'repeatable'    => true,
    'default'       => 'y',
    'label' => array( 
        'x' => 'X',
        'y' => 'Y',     
        'z' => 'Z',     
    ),
)
EOD
) . "</pre>")), array('field_id' => 'select_sortable', 'title' => __('Sortable', 'admin-page-framework-loader'), 'type' => 'select', 'sortable' => true, 'default' => 'iii', 'before_label' => "<span style='vertical-align:baseline; min-width: 140px; display:inline-block; margin-top: 0.5em; padding-bottom: 0.2em;'>" . __('Sortable Item', 'admin-page-framework-loader') . "</span>", 'label' => array('i' => 'I', 'ii' => 'II', 'iii' => 'III', 'iiv' => 'IIV'), array(), array(), array(), 'description' => array("<pre class='field-argument-example'>" . $oFactory->oWPRMParser->getSyntaxHighlightedPHPCode(<<<EOD
array(
    'type'          => 'select',
    'sortable'      => true,
    'default'       => 'iii',
    'label'         => array( 
        'i'     => 'I',
        'ii'    => 'II',    
        'iii'   => 'III',     
        'iiv'   => 'IIV',     
    ),
    array(), // the second item 
    array(), // the third item
    array(), // the forth item
)
EOD
) . "</pre>")));
    }
APF_Demo_BuiltinFieldTypes_Selector_Select