public function SolrFieldTypeForm::save in Search API Multilingual Solr Search 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 77
Class
- SolrFieldTypeForm
- Class SolrFieldTypeForm.
Namespace
Drupal\search_api_solr_multilingual\FormCode
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) {
$this
->messenger()
->addStatus($this
->t('Saved the %label Solr Field Type.', array(
'%label' => $solr_field_type
->label(),
)));
}
else {
$this
->messenger()
->addStatus($this
->t('The %label Solr Field Type was not saved.', array(
'%label' => $solr_field_type
->label(),
)));
}
$form_state
->setRedirectUrl($solr_field_type
->toUrl('collection'));
}