function cck_select_other_options in CCK Select Other 6
Same name and namespace in other branches
- 7.2 cck_select_other.module \cck_select_other_options()
- 7 cck_select_other.module \cck_select_other_options()
Helper function for finding the options list for this field.
7 calls to cck_select_other_options()
- CCKSelectOtherBasicTest::testSelectFieldValue in tests/
cck_select_other.test - Modify node with a new value from select list options
- CCKSelectOtherTest::setUp in tests/
cck_select_other.test - Implementation of setUp() method
- CCKSelectOtherTest::testSelectOtherOptions in tests/
cck_select_other.test - cck_select_other_handler_field::render in views/
cck_select_other_handler_field.inc - cck_select_other_handler_filter::get_value_options in views/
cck_select_other_handler_filter.inc
File
- ./
cck_select_other.module, line 169 - Implements a select list widget that lets a user provide an alternate option.
Code
function cck_select_other_options($field) {
$options = eval($field['widget']['select_list_options_php']);
if (empty($options)) {
$options_str = $field['widget']['select_list_options'];
if (!empty($options_str)) {
$options_arr = preg_split("/[\r]?[\n]/", $options_str);
if (count($options_arr) > 0) {
foreach ($options_arr as $option_str) {
$option_arr = preg_split("/\\|/", $option_str);
if (count($option_arr) == 2) {
$options[check_plain($option_arr[0])] = t('!option', array(
'!option' => $option_arr[1],
));
}
else {
$options[check_plain($option_arr[0])] = t('!option', array(
'!option' => $option_arr[0],
));
}
}
}
}
}
else {
foreach ($options as $key => $option) {
if (!is_numeric($key)) {
$key = check_plain($key);
}
$options[$key] = t('!option', array(
'!option' => $option,
));
}
}
if (!isset($options['other'])) {
$options['other'] = t('Other');
}
return $options;
}