You are here

function civicrm_entity_get_field_options in CiviCRM Entity 7.2

Utility function to get the options for a civicrm options field for the widget metadata

Parameters

$field_name:

$civicrm_entity:

Return value

array

1 call to civicrm_entity_get_field_options()
civicrm_entity_get_field_widget in ./civicrm_entity.module
Utility function that takes the provided field specs from a getfields call and builds a widget property array on the property metadata info

File

./civicrm_entity.module, line 2683

Code

function civicrm_entity_get_field_options($field_name, $civicrm_entity) {
  $result = civicrm_api($civicrm_entity, 'getoptions', array(
    'sequential' => 1,
    'version' => 3,
    'field' => $field_name,
  ));
  $options = array(
    NULL => '- No Value -',
  );
  if (!$result['is_error']) {
    foreach ($result['values'] as $option) {
      $options[$option['key']] = $option['value'];
    }
  }
  return $options;
}