Redux Framework从select字段而不是id(key)获取文本

时间:2015-03-16 05:39:15

标签: php templates wordpress-plugin wordpress-theming

是否可以在选项中输入文本而不是id(" key")?例如。

$fields = array(
    'id'       => 'opt-select',
    'type'     => 'select',
    'title'    => __('Select Option', 'redux-framework-demo'), 
    'subtitle' => __('No validation can be done on this field type', 'redux-framework-demo'),
    'desc'     => __('This is the description field, again good for additional info.', 'redux-framework-demo'),
    // Must provide key => value pairs for select options
    'options'  => array(
        '1' => 'Opt 1',
        '2' => 'Opt 2',
        '3' => 'Opt 3'
    ),
    'default'  => '2',
);

而不是获取

global $redux_demo;
echo 'Single Select value: ' . $redux_demo['opt-select']; 

这将返回1,2,3。 但我想获得Opt 1,Opt 2,Opt 3.这可能吗?

1 个答案:

答案 0 :(得分:0)

Not really. You're declaring a key value set. The key is simply a pointer to the value. If you want the pointer and the key to be the same, then use then provide a non-multi dimensional array to denote that the key and the value are one and the same.