public function AutocompletionConfigurationListBuilder::submitForm in Search Autocomplete 8
Same name and namespace in other branches
- 2.x src/Controller/AutocompletionConfigurationListBuilder.php \Drupal\search_autocomplete\Controller\AutocompletionConfigurationListBuilder::submitForm()
Implements \Drupal\Core\Form\FormInterface::submitForm().
Form submission handler for the main block administration form.
Overrides FormInterface::submitForm
File
- src/
Controller/ AutocompletionConfigurationListBuilder.php, line 116
Class
- AutocompletionConfigurationListBuilder
- Provides a listing of autocompletion_configuration entities.
Namespace
Drupal\search_autocomplete\ControllerCode
public function submitForm(array &$form, FormStateInterface $form_state) {
$values = $form_state
->getValues();
// Save global configurations.
Drupal::configFactory()
->getEditable('search_autocomplete.settings')
->set('admin_helper', $values['admin_helper'])
->save();
// Save all configuration activations.
$entities = $this->storage
->loadMultiple(array_keys($form_state
->getValue('configs')));
foreach ($entities as $entity_id => $entity) {
$entity_values = $form_state
->getValue([
'configs',
$entity_id,
]);
$entity
->setStatus($entity_values['enabled']);
$entity
->save();
}
drupal_set_message($this
->t('Data have been saved.'));
}