You are here

function eck_property_widget_type_options in Entity Construction Kit (ECK) 7.3

Returns an array of widget type options for an ECK property type.

If no property type is provided, returns a nested array of all widget types, keyed by property type.

4 calls to eck_property_widget_type_options()
eck_form_field_ui_field_overview_form_alter in ./eck.module
Adds a manage properties section.
eck_form_field_ui_field_overview_form_validate in ./eck.module
Validates the add property as extra field of field_ui_field_overview_form().
eck__extra_field_widget_form in ./eck.bundle.inc
Form for changing the widget type for a given entity property.
eck__extra_field_widget_form_validate in ./eck.bundle.inc
Validation callback.

File

./eck.module, line 609

Code

function eck_property_widget_type_options($property_type = NULL, $by_label = FALSE) {
  $options =& drupal_static(__FUNCTION__);
  if (!isset($options)) {
    $options = array();
    $property_types = eck_get_property_types();
    foreach (eck_property_info_widget_types() as $name => $widget_type) {
      foreach ($widget_type['property types'] as $widget_property_type) {

        // Check that the field type exists.
        if (isset($property_types[$widget_property_type])) {
          $options[$widget_property_type][$name] = $widget_type['label'];
        }
      }
    }
  }
  if (isset($property_type)) {
    return !empty($options[$property_type]) ? $options[$property_type] : array();
  }
  if ($by_label) {
    $property_types = eck_get_property_types();
    $options_by_label = array();
    foreach ($options as $property_type => $widgets) {
      $options_by_label[$property_types[$property_type]['label']] = $widgets;
    }
    return $options_by_label;
  }
  return $options;
}