You are here

function relation_entity_collector_save in Relation 7

Submit handler for the save button.

1 string reference to 'relation_entity_collector_save'
relation_entity_collector in relation_entity_collector/relation_entity_collector.module
The entity_collector form.

File

relation_entity_collector/relation_entity_collector.module, line 435
Relation Entity Collector Block.

Code

function relation_entity_collector_save($form, $form_state) {
  $relation = _relation_entity_collector_get_entity();
  if ($relation) {
    array_multisort($form_state['values']['table']['weight'], SORT_ASC, $relation->endpoints[LANGUAGE_NONE]);
    $rid = relation_save($relation);
    if ($rid) {
      $relation_uri = entity_uri('relation', $relation);
      $link = l(relation_get_type_label($relation), $relation_uri['path']);
      $list = _relation_stored_entity_keys_list();
      $rendered_list = drupal_render($list);
      $t_arguments = array(
        '!link' => $link,
        '!list' => $rendered_list,
      );
      if (isset($_SESSION['relation_edit'])) {
        $message = t('Edited !link containing !list', $t_arguments);
      }
      else {
        $message = t('Created new !link from !list', $t_arguments);
      }
      drupal_set_message($message);
      relation_entity_collector_clear($form, $form_state);
    }
    else {
      drupal_set_message(t('Relation not created.'), 'error');
    }
  }
}