You are here

function eck_eck_property_widget_form in Entity Construction Kit (ECK) 7.3

Implements hook_eck_property_widget_form().

Returns the widget forms for various ECK defined property widgets. These forms allow the user to update property data when creating/editing entities.

See also

eck_eck_property_widget_info()

hook_eck_property_widget_form()

hook_eck_property_widget_settings_form()

File

./eck.property_widgets.inc, line 69
Contains the hooks for implementing ECK's default property widgets.

Code

function eck_eck_property_widget_form(&$form, &$form_state, $property_name, $bundle_property_config, $language, $value, $element) {
  if ($bundle_property_config['widget']['type'] == 'text') {
    $element += array(
      '#type' => 'textfield',
      '#default_value' => isset($value) ? $value : NULL,
      '#size' => $bundle_property_config['widget']['settings']['size'],
      '#maxlength' => $bundle_property_config['widget']['settings']['max_length'],
      '#attributes' => array(
        'class' => array(
          'text-full',
        ),
      ),
    );
  }
  if ($bundle_property_config['widget']['type'] == 'options') {
    $options = array();
    $options_string = $bundle_property_config['widget']['settings']['options'];
    if (!empty($options_string)) {
      $option_lines = explode("\n", $options_string);
      foreach ($option_lines as $line) {
        $kv = explode("|", $line);
        $options[$kv[0]] = $kv[1];
      }
    }
    $element += array(
      '#type' => 'radios',
      '#default_value' => isset($value) ? $value : NULL,
      '#options' => $options,
    );
  }
  if ($bundle_property_config['widget']['type'] == 'language_toggle') {
    global $language;
    if (module_exists('locale')) {
      $element += array(
        '#type' => 'select',
        '#default_value' => isset($value) ? $value : $language->language,
        '#options' => array(
          LANGUAGE_NONE => t('Language neutral'),
        ) + locale_language_list('name'),
      );
    }
    else {
      $element += array(
        '#type' => 'value',
        '#value' => !isset($value) ? $value : $language->language,
      );
    }
  }
  return $element;
}