You are here

public function LingotekProfileFormBase::save in Lingotek Translation 3.4.x

Same name and namespace in other branches
  1. 8.2 src/Form/LingotekProfileFormBase.php \Drupal\lingotek\Form\LingotekProfileFormBase::save()
  2. 4.0.x src/Form/LingotekProfileFormBase.php \Drupal\lingotek\Form\LingotekProfileFormBase::save()
  3. 3.0.x src/Form/LingotekProfileFormBase.php \Drupal\lingotek\Form\LingotekProfileFormBase::save()
  4. 3.1.x src/Form/LingotekProfileFormBase.php \Drupal\lingotek\Form\LingotekProfileFormBase::save()
  5. 3.2.x src/Form/LingotekProfileFormBase.php \Drupal\lingotek\Form\LingotekProfileFormBase::save()
  6. 3.3.x src/Form/LingotekProfileFormBase.php \Drupal\lingotek\Form\LingotekProfileFormBase::save()
  7. 3.5.x src/Form/LingotekProfileFormBase.php \Drupal\lingotek\Form\LingotekProfileFormBase::save()
  8. 3.6.x src/Form/LingotekProfileFormBase.php \Drupal\lingotek\Form\LingotekProfileFormBase::save()
  9. 3.7.x src/Form/LingotekProfileFormBase.php \Drupal\lingotek\Form\LingotekProfileFormBase::save()
  10. 3.8.x src/Form/LingotekProfileFormBase.php \Drupal\lingotek\Form\LingotekProfileFormBase::save()

Form submission handler for the 'save' action.

Normally this method should be overridden to provide specific messages to the user and redirect the form after the entity has been saved.

Parameters

array $form: An associative array containing the structure of the form.

\Drupal\Core\Form\FormStateInterface $form_state: The current state of the form.

Return value

int Either SAVED_NEW or SAVED_UPDATED, depending on the operation performed.

Overrides EntityForm::save

2 calls to LingotekProfileFormBase::save()
LingotekProfileAddForm::save in src/Form/LingotekProfileAddForm.php
Form submission handler for the 'save' action.
LingotekProfileEditForm::save in src/Form/LingotekProfileEditForm.php
Form submission handler for the 'save' action.
2 methods override LingotekProfileFormBase::save()
LingotekProfileAddForm::save in src/Form/LingotekProfileAddForm.php
Form submission handler for the 'save' action.
LingotekProfileEditForm::save in src/Form/LingotekProfileEditForm.php
Form submission handler for the 'save' action.

File

src/Form/LingotekProfileFormBase.php, line 336

Class

LingotekProfileFormBase
Provides a common base class for Profile forms.

Namespace

Drupal\lingotek\Form

Code

public function save(array $form, FormStateInterface $form_state) {

  /** @var \Drupal\lingotek\Entity\LingotekProfile $profile */
  $profile = $this
    ->getEntity();

  /** @var \Drupal\Core\Form\FormInterface $subform */
  $form_object = new LingotekIntelligenceMetadataForm();
  $input = $form_state
    ->getUserInput();
  $inner_form_state = new FormState();
  $inner_form_state
    ->addBuildInfo('args', [
    $this
      ->getRequest(),
    $profile,
  ]);
  $inner_form_state
    ->setFormObject($form_object);
  $inner_form_state
    ->setUserInput($form_state
    ->getUserInput());
  $inner_form_state
    ->setValue('intelligence_metadata', $input['intelligence_metadata']);
  $subform = [];
  $form_object
    ->submitForm($subform, $inner_form_state);
  $profile
    ->setIntelligenceMetadataOverrides($form_state
    ->getValue([
    'intelligence_metadata_overrides',
    'override',
  ]));
  parent::save($form, $form_state);
}