public static function EntityReference_SelectionHandler_Views::settingsForm

cis7 EntityReference_SelectionHandler_Views.class.php public static EntityReference_SelectionHandler_Views::settingsForm($field, $instance)
cle7 EntityReference_SelectionHandler_Views.class.php public static EntityReference_SelectionHandler_Views::settingsForm($field, $instance)
elmsmedia7 EntityReference_SelectionHandler_Views.class.php public static EntityReference_SelectionHandler_Views::settingsForm($field, $instance)
icor7 EntityReference_SelectionHandler_Views.class.php public static EntityReference_SelectionHandler_Views::settingsForm($field, $instance)
meedjum_blog7 EntityReference_SelectionHandler_Views.class.php public static EntityReference_SelectionHandler_Views::settingsForm($field, $instance)
mooc7 EntityReference_SelectionHandler_Views.class.php public static EntityReference_SelectionHandler_Views::settingsForm($field, $instance)

Implements EntityReferenceHandler::settingsForm().

Overrides EntityReference_SelectionHandler::settingsForm

File

sites/all/modules/ulmus/entityreference/plugins/selection/EntityReference_SelectionHandler_Views.class.php, line 23

Class

EntityReference_SelectionHandler_Views
Entity handler for Views.

Code

public static function settingsForm($field, $instance) {
  $view_settings = empty($field['settings']['handler_settings']['view']) ? '' : $field['settings']['handler_settings']['view'];
  $displays = views_get_applicable_views('entityreference display');
  // Filter views that list the entity type we want, and group the separate
  // displays by view.
  $entity_info = entity_get_info($field['settings']['target_type']);
  $options = array();
  foreach ($displays as $data) {
    list($view, $display_id) = $data;
    if ($view->base_table == $entity_info['base table']) {
      $options[$view->name . ':' . $display_id] = $view->name . ' - ' . $view->display[$display_id]->display_title;
    }
  }

  // The value of the 'view_and_display' select below will need to be split
  // into 'view_name' and 'view_display' in the final submitted values, so
  // we massage the data at validate time on the wrapping element (not
  // ideal).
  $form['view']['#element_validate'] = array('entityreference_view_settings_validate');

  if ($options) {
    $default = !empty($view_settings['view_name']) ? $view_settings['view_name'] . ':' . $view_settings['display_name'] : NULL;
    $form['view']['view_and_display'] = array(
      '#type' => 'select',
      '#title' => t('View used to select the entities'),
      '#required' => TRUE,
      '#options' => $options,
      '#default_value' => $default,
      '#description' => '<p>' . t('Choose the view and display that select the entities that can be referenced.<br />Only views with a display of type "Entity Reference" are eligible.') . '</p>',
    );

    $default = !empty($view_settings['args']) ? implode(', ', $view_settings['args']) : '';
    $form['view']['args'] = array(
      '#type' => 'textfield',
      '#title' => t('View arguments'),
      '#default_value' => $default,
      '#required' => FALSE,
      '#description' => t('Provide a comma separated list of arguments to pass to the view.'),
    );
  }
  else {
    $form['view']['no_view_help'] = array(
      '#markup' => '<p>' . t('No eligible views were found. <a href="@create">Create a view</a> with an <em>Entity Reference</em> display, or add such a display to an <a href="@existing">existing view</a>.', array(
        '@create' => url('admin/structure/views/add'),
        '@existing' => url('admin/structure/views'),
      )) . '</p>',
    );
  }
  return $form;
}
Error | ELMSLN API

Error

×

Error message

  • Warning: Cannot modify header information - headers already sent by (output started at /var/www/html/elmsln_community/api.elmsln.org/includes/common.inc:2791) in drupal_send_headers() (line 1499 of /var/www/html/elmsln_community/api.elmsln.org/includes/bootstrap.inc).
  • Error: Call to undefined function apc_delete() in DrupalAPCCache->clear() (line 289 of /var/www/html/elmsln_community/api.elmsln.org/sites/all/modules/apc/drupal_apc_cache.inc).
The website encountered an unexpected error. Please try again later.