You are here

public function FlexiformElementNodeAuthor::formSubmit in Flexiform 7

Submit the form element.

Overrides FlexiformElement::formSubmit

File

includes/element/node_author.element.inc, line 72
Contains class for the Node author element.

Class

FlexiformElementNodeAuthor
Class to add the node author field to a form.

Code

public function formSubmit($form, &$form_state, $entity, $language = LANGUAGE_NONE) {
  $author = $this
    ->formExtractValues($form, $form_state, $entity);
  $entity->name = $author;

  // A user might assign the node author by entering a user name in the node
  // form, which we then need to translate to a user ID.
  if (isset($entity->name)) {
    if ($account = user_load_by_name($entity->name)) {
      $entity->uid = $account->uid;
    }
    else {
      $entity->uid = 0;
    }
  }
}