查找一個選單的欄位的可選項 Get display values of a dropdown list

在 views 的 $views->exposed filter 可以提取已經提交的表單值
但除了值之外, 一般還需要欄位的其他資料,
例如欄位旳值和顯示值不一樣的時候,

可以使用:

<?php
//field_hotel_group 是欄位名
$mappings = optionwidgets_options(content_fields('field_hotel_group'));
?>

可得到類似:

你便可以自己再處理了


You can get the value of view's exposed filter value by $views->exposed filter
But other than value, the display value is also needed
Especially when the submit value is not the same as display value:

Actually you can use:

<?php
//field_hotel_group is the field name
$mappings = optionwidgets_options(content_fields('field_hotel_group'));
?>

and you will obtain:

and then you can map back those values for your own use.
AttachmentSize
Image icon form-options-sample.JPG25.1 KB
Image icon form-options.JPG27.49 KB
Google