You are here

function inline_entity_form_field_widget_settings_form in Inline Entity Form 7

Implements hook_field_widget_settings_form().

File

./inline_entity_form.module, line 242
Provides a widget for inline management (creation, modification, removal) of referenced entities. The primary use case is the parent -> children one (for example, order -> line items), where the child entities are never managed outside the…

Code

function inline_entity_form_field_widget_settings_form($field, $instance) {
  $widget = $instance['widget'];
  $settings = $widget['settings'];
  $controller = inline_entity_form_get_controller($instance);

  // The current entity type is not supported, execution can't continue.
  if (!$controller) {
    return array();
  }
  $element = array();

  // The fields are not editable from the UI for now.
  $element['fields'] = array(
    '#type' => 'value',
    '#value' => $settings['fields'],
  );

  // Add entity type specific settings if they exist.
  $settings_form = $controller
    ->settingsForm($field, $instance);
  if (!empty($settings_form)) {
    $entity_info = entity_get_info($controller
      ->entityType());
    $element['type_settings'] = array(
      '#type' => 'fieldset',
      '#title' => t('Inline Entity Form: %type', array(
        '%type' => $entity_info['label'],
      )),
    );
    $element['type_settings'] += $settings_form;
  }
  return $element;
}