You are here

public function ParseNameWidget::submit in Bibliography & Citation 2.0.x

Same name and namespace in other branches
  1. 8 modules/bibcite_entity/src/Plugin/Field/FieldWidget/ParseNameWidget.php \Drupal\bibcite_entity\Plugin\Field\FieldWidget\ParseNameWidget::submit()

Widget submit callback for the "Parse" button.

Parameters

array $form: Form array.

\Drupal\Core\Form\FormStateInterface $form_state: Form state object.

File

modules/bibcite_entity/src/Plugin/Field/FieldWidget/ParseNameWidget.php, line 79

Class

ParseNameWidget
Plugin implementation of the 'bibcite_parse_name' widget.

Namespace

Drupal\bibcite_entity\Plugin\Field\FieldWidget

Code

public function submit(array &$form, FormStateInterface $form_state) {

  /** @var \Drupal\bibcite_entity\Entity\ContributorInterface $entity */
  $entity = $form_state
    ->getFormObject()
    ->getEntity();
  $entity->name = $form_state
    ->getValue('name');

  // Unset name parts from user input so default values on form are
  // populated from entity instead of submitted values.
  $user_input = $form_state
    ->getUserInput();
  foreach (Contributor::getNameParts() as $part) {
    unset($user_input[$part]);
  }
  $form_state
    ->setUserInput($user_input);
  $form_state
    ->setRebuild();
}