简体   繁体   English

Redux Framework从选择字段获取文本,而不是ID(密钥)

[英]Redux Framework get text from select field instead of id (key)

Is it possible to get the text in options instead of the id ("key")? 是否可以在选项而不是id(“键”)中获取文本? For example. 例如。

$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',
);

Instead of get 而不是得到

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

This will return 1, 2, 3. But I want to get Opt 1, Opt 2, Opt 3. Is this possible? 这将返回1、2、3。但是我要获取选项1,选项2,选项3。这可能吗?

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. 如果希望指针和键相同,则使用然后提供一个非多维数组来表示键和值相同。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM