You are here

function eck_language_property_widget in Entity Construction Kit (ECK) 7.3

Same name and namespace in other branches
  1. 7.2 plugins/property_behavior/language.inc \eck_language_property_widget()

Language widget.

Select one of the enabled languages.

1 string reference to 'eck_language_property_widget'
language.inc in plugins/property_behavior/language.inc

File

plugins/property_behavior/language.inc, line 64

Code

function eck_language_property_widget($property, $vars) {
  if (module_exists('locale')) {
    $entity = $vars['entity'];
    $language = isset($entity->{$property}) ? $entity->{$property} : '';
    if (eck_language_bundle_multilingual($entity)) {
      return array(
        '#type' => 'select',
        '#title' => $vars['properties'][$property]['label'],
        '#default_value' => $language,
        '#options' => array(
          LANGUAGE_NONE => t('Language neutral'),
        ) + locale_language_list('name'),
      );
    }
    else {
      $default = language_default();
      return array(
        '#type' => 'value',
        '#value' => !empty($language) ? $language : $default->language,
      );
    }
  }
}