function ctools_context_entity_settings_form_validate

cis7 entity.inc ctools_context_entity_settings_form_validate($form, &$form_state)
cle7 entity.inc ctools_context_entity_settings_form_validate($form, &$form_state)
elmsmedia7 entity.inc ctools_context_entity_settings_form_validate($form, &$form_state)
icor7 entity.inc ctools_context_entity_settings_form_validate($form, &$form_state)
meedjum_blog7 entity.inc ctools_context_entity_settings_form_validate($form, &$form_state)
mooc7 entity.inc ctools_context_entity_settings_form_validate($form, &$form_state)

Validate a node.

File

sites/all/modules/ulmus/ctools/plugins/contexts/entity.inc, line 161
Plugin to provide a node context. A node context is a node wrapped in a context object that can be utilized by anything that accepts contexts.

Code

function ctools_context_entity_settings_form_validate($form, &$form_state) {
  // Validate the autocomplete
  if (empty($form_state['values']['entity_id']) && empty($form_state['values']['entity'])) {
    form_error($form['entity'], t('You must select an entity.'));
    return;
  }

  if (empty($form_state['values']['entity'])) {
    return;
  }

  $id = $form_state['values']['entity'];
  $preg_matches = array();
  $match = preg_match('/\[id: (\d+)\]/', $id, $preg_matches);
  if (!$match) {
    $match = preg_match('/^id: (\d+)/', $id, $preg_matches);
  }

  if ($match) {
    $id = $preg_matches[1];
  }
  if (is_numeric($id)) {
    $entity = entity_load($form_state['values']['entity_type'], array($id));
    $entity = $entity[$id];
  }
  else {
    $entity_info = entity_get_info($form_state['values']['entity_type']);
    $field = $entity_info['entity keys']['label'];
    $entity = entity_load($form_state['values']['entity_type'], FALSE, array($field => $id));
  }

  // Do not allow unpublished nodes to be selected by unprivileged users
  // || (empty($node->status) && !(user_access('administer nodes'))) need a new sanity check at some point.
  if (!$entity) {
    form_error($form['entity'], t('Invalid entity selected.'));
  }
  else {
    $entity_id = entity_extract_ids($form_state['values']['entity_type'], $entity);
    form_set_value($form['entity_id'], $entity_id[0], $form_state);
  }
}
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.