-
Notifications
You must be signed in to change notification settings - Fork 0
The select field
The select field is a basic field type. It's just a drop down select input where only one option can be selected.
To creat a select field option you need to create an array within the $sections => fields array. Like so:
<?php
array(
'id' => '1', //must be unique
'type' => 'select', //the field type
'title' => __('Select Option', Redux_TEXT_DOMAIN),
'sub_desc' => __('This is a little space under the Field Title in the Options table', Redux_TEXT_DOMAIN),
'desc' => __('This is the description field, again good for additional info.', Redux_TEXT_DOMAIN),
'options' => array(
'1' => __('Option 1', Redux_TEXT_DOMAIN),
'2' => __('Option 2', Redux_TEXT_DOMAIN)
),// You must provide a set of key => value pairs
'std' => '2'//this should be the key as defined above
)
?>With the above array we will be creating a radio field with the options:
id 1
title Select Option
options Explained further down
These are the only required fields, the rest can be removed if not wanted. But it's always a good idea to explain the option using the sub_desc and desc fields.
We have also set the std attribute to 2 this will automatically set the option to value 2 and display that select option as selected by default.
You will also notice there is a Options section in the array. This is where you define the Option value and title of each select option. It needs to be provided as a key => value pair for each select option in the field type.