public function BlocktabsEditForm::tabSave in Block Tabs 8
Submit handler for tab.
File
- src/
Form/ BlocktabsEditForm.php, line 195
Class
- BlocktabsEditForm
- Controller for blocktabs edit form.
Namespace
Drupal\blocktabs\FormCode
public function tabSave($form, FormStateInterface $form_state) {
$this
->save($form, $form_state);
// Check if this field has any configuration options.
$tab = $this->tabManager
->getDefinition($form_state
->getValue('new'));
// Load the configuration form for this option.
if (is_subclass_of($tab['class'], '\\Drupal\\blocktabs\\ConfigurableTabInterface')) {
$form_state
->setRedirect('blocktabs.tab_add_form', [
'blocktabs' => $this->entity
->id(),
'tab' => $form_state
->getValue('new'),
], [
'query' => [
'weight' => $form_state
->getValue('weight'),
],
]);
}
else {
$tab = [
'id' => $tab['id'],
'data' => [],
'weight' => $form_state
->getValue('weight'),
];
$tab_id = $this->entity
->addTab($tab);
$this->entity
->save();
if (!empty($tab_id)) {
\Drupal::messenger()
->addMessage($this
->t('The tab was successfully added.'));
}
}
}