public function CancelButtonSettingsForm::submitForm in Entity Form Cancel Button 8
Form submission handler.
Parameters
array $form: An associative array containing the structure of the form.
\Drupal\Core\Form\FormStateInterface $form_state: The current state of the form.
Overrides ConfigFormBase::submitForm
File
- src/
Form/ CancelButtonSettingsForm.php, line 271
Class
- CancelButtonSettingsForm
- Configure generic settings for the Cancel Button.
Namespace
Drupal\cancel_button\FormCode
public function submitForm(array &$form, FormStateInterface $form_state) {
$config = $this
->config('cancel_button.settings');
$result = $this
->getEntityTypesToDisplay();
$entity_types = $result["entity_types"];
$bundles = $result["bundles"];
$entity_types += [
'default' => NULL,
];
// If the entity type is not fieldable (doesn't have bundles), store config
// for entity type, otherwise store config for a combination of entity type
// and bundle.
foreach ($entity_types as $id => $type) {
if (array_key_exists($id, $bundles) && count($bundles[$id]) > 0) {
foreach ($bundles[$id] as $bundle) {
$config
->set('entity_type_cancel_destination.' . $id . '_' . $bundle
->id() . '.path', $form_state
->getValue($id . '_' . $bundle
->id() . '_cancel_destination'));
}
}
else {
$config
->set('entity_type_cancel_destination.' . $id . '.path', $form_state
->getValue($id . '_cancel_destination'));
}
$config
->set('entity_type_cancel_destination.' . $id . '.enabled', (bool) $form_state
->getValue($id . '_cancel_enabled'));
}
$config
->save();
parent::submitForm($form, $form_state);
}