You are here

public function SolrFieldTypeForm::save in Apache Solr Multilingual 8

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

File

src/Form/SolrFieldTypeForm.php, line 81
Contains Drupal\apachesolr_multilingual\Form\SolrFieldTypeForm.

Class

SolrFieldTypeForm
Class SolrFieldTypeForm.

Namespace

Drupal\apachesolr_multilingual\Form

Code

public function save(array $form, FormStateInterface $form_state) {
  $solr_field_type = $this->entity;
  $solr_field_type
    ->setFieldTypeAsJson($form_state
    ->getValue('field_type'));
  $solr_field_type
    ->setTextFiles($form_state
    ->getValue('text_files'));
  $status = $solr_field_type
    ->save();
  if ($status) {
    drupal_set_message($this
      ->t('Saved the %label Solr Field Type.', array(
      '%label' => $solr_field_type
        ->label(),
    )));
  }
  else {
    drupal_set_message($this
      ->t('The %label Solr Field Type was not saved.', array(
      '%label' => $solr_field_type
        ->label(),
    )));
  }
  $form_state
    ->setRedirectUrl($solr_field_type
    ->urlInfo('collection'));
}