You are here

function eck__extra_field_widget_form in Entity Construction Kit (ECK) 7.3

Form for changing the widget type for a given entity property.

Parameters

array $form: The property widget form.

array $form_state: The current state of the form.

string $entity_type_name: The machine name of the entity type.

string $bundle_type: The machine name of the bundle type.

string $property_name: The machine name of the entity property being included as an extra field.

Return value

array An array comprising the form for changing the property's widget.

1 string reference to 'eck__extra_field_widget_form'
eck__entity__menu in ./eck.entity.inc
Entity related menu items.

File

./eck.bundle.inc, line 715

Code

function eck__extra_field_widget_form($form, &$form_state, $entity_type_name, $bundle_type, $property_name) {
  $entity_type = entity_type_load($entity_type_name);
  $bundle = bundle_load($entity_type_name, $bundle_type);
  drupal_set_title($bundle->config['extra_fields'][$property_name]['form']['label']);
  $default_widget = !empty($bundle->config['extra_fields'][$property_name]['form']['widget']['type']) ? $bundle->config['extra_fields'][$property_name]['form']['widget']['type'] : '';
  $form = array(
    '#entity_type' => $entity_type,
    '#bundle' => $bundle,
    '#property_name' => $property_name,
    '#default_widget' => $default_widget,
  );
  $form['widget'] = array(
    '#type' => 'fieldset',
    '#title' => t('Change Widget'),
    '#weight' => 5,
    '#collapsible' => FALSE,
  );
  $form['widget']['widget_type'] = array(
    '#type' => 'select',
    '#title' => t('Widget for managed property'),
    '#options' => eck_property_widget_type_options($entity_type->properties[$property_name]['type']),
    '#empty_option' => t('- Select a widget -'),
    '#description' => t('The type of form element you would like to present to the user when managing this property for the %bundle type.', array(
      '%type' => $bundle->label,
    )),
    '#default_value' => $default_widget,
  );
  $form['actions'] = array(
    '#type' => 'actions',
  );
  $form['actions']['submit'] = array(
    '#type' => 'submit',
    '#value' => t('Continue'),
  );
  return $form;
}