You are here

function certificate_get_selected_type_options in Certificate 6

Get certificate type field options.

Return value

the selected field's options as an array.

4 calls to certificate_get_selected_type_options()
certificate_field_grouping_form in ./certificate.admin.inc
Grouping
certificate_settings_form_submit in ./certificate.admin.inc
Submit handler for global field mapping form.
certificate_single in ./certificate.pages.inc
Generate a single certificate.
certificate_type_mapping_form in ./certificate.admin.inc
Returns the form for the per-node certificate settings.

File

./certificate.module, line 387
Certificate module.

Code

function certificate_get_selected_type_options() {

  // Get selected field name.
  $selected = certificate_get_selected_type();

  // Add 'Default' to beginning of options array, whether or not an option field is selected.
  $field_options = array(
    'default' => t('Default'),
  );

  // Get selected field's options.
  if ($selected == 'no field') {
    return NULL;
  }
  else {
    $field = content_fields($selected);

    // Remove non-keyed values (for instance, if '|Please select' workaround is used).
    $allowed_values = content_allowed_values($field);
    $keys = $allowed_values ? array_keys($allowed_values) : array();
    foreach ($keys as $key) {
      if ($key != '') {
        $allowed_values_keys[$key] = $allowed_values[$key];
      }
    }

    // Merge allowed values with default option.
    $field_options_array = $allowed_values_keys;
  }
  return $field_options_array;
}