Drupal:如何从模块配置表单中检索 select 类型值?

Drupal: how do I retrieve the select type values from a module Config form?

我是 Drupal 的新手,正在尝试构建一个模块。该模块的部分功能是允许您从下拉字段中添加预设 类。

在大多数情况下,我已经完成了这项工作,但一方面:我似乎只能检索 select 选项名称,而不是它的值。

我的代码如下。

在配置表单创建函数中我有:

$styles = array(
  'None' => '',
  'Blue Buttons' => 'btn blue-btn',
  'Red Buttons' => 'btn red-btn',
);

$mymodule_form['style'] = array(
  '#type' => 'select',
  '#required' => TRUE,
  '#title' => t('Style'),
  '#description' => t('Style for buttons'),
  '#default_value' => $form_values['style'],
  '#empty_option' => t('- Select -'),
  '#options' => drupal_map_assoc(array_keys($styles)),
);

但是,当我 运行 dpm($this->options['style']); 稍后在我的代码中想要使用这些样式时,我得到了键名 return(例如 Button Red

有人知道我如何检索这些值吗?

我在不需要的时候使用 drupal_map_assoc

'#options' => $styles,

很好。

(另外,我的键名和键值用错了)。