You are here

function optionwidgets_options in Content Construction Kit (CCK) 6.2

Same name and namespace in other branches
  1. 6.3 modules/optionwidgets/optionwidgets.module \optionwidgets_options()
  2. 6 modules/optionwidgets/optionwidgets.module \optionwidgets_options()

Helper function for finding the allowed values list for a field.

See if there is a module hook for the option values. Otherwise, try content_allowed_values() for an options list.

Parameters

$field: The field whose allowed values are requested.

$flatten: Optional. Use TRUE to return a flattened array (default). FALSE can be used to support optgroups for select widgets when allowed values list is generated using PHP code.

5 calls to optionwidgets_options()
optionwidgets_buttons_process in modules/optionwidgets/optionwidgets.module
Process an individual element.
optionwidgets_data2form in modules/optionwidgets/optionwidgets.module
Helper function to transpose the values as stored in the database to the format the widget needs. Can be called anywhere this transformation is needed.
optionwidgets_form2data in modules/optionwidgets/optionwidgets.module
Helper function to transpose the values returned by submitting the widget to the format to be stored in the field. Can be called anywhere this transformation is needed.
optionwidgets_onoff_process in modules/optionwidgets/optionwidgets.module
Process an individual element.
optionwidgets_select_process in modules/optionwidgets/optionwidgets.module
Process an individual element.

File

modules/optionwidgets/optionwidgets.module, line 400
Defines selection, check box and radio button widgets for text and numeric fields.

Code

function optionwidgets_options($field, $flatten = TRUE) {
  $function = $field['module'] . '_allowed_values';
  $options = function_exists($function) ? $function($field) : (array) content_allowed_values($field, $flatten);

  // Add an empty choice for :
  // - non required radios
  // - non required selects
  if (!$field['required']) {
    if (in_array($field['widget']['type'], array(
      'optionwidgets_buttons',
      'nodereference_buttons',
      'userreference_buttons',
    )) && !$field['multiple'] || in_array($field['widget']['type'], array(
      'optionwidgets_select',
      'nodereference_select',
      'userreference_select',
    ))) {
      $options = array(
        '' => theme('optionwidgets_none', $field),
      ) + $options;
    }
  }
  return $options;
}