public function CctagsEditItemForm::submitForm in cctags 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 FormInterface::submitForm
File
- src/
Form/ CctagsEditItemForm.php, line 257
Class
- CctagsEditItemForm
- Class LoginDisableSettingsForm.
Namespace
Drupal\cctags\FormCode
public function submitForm(array &$form, FormStateInterface $form_state, $cctid = NULL) {
$conn = Database::getConnection();
$id = $form_state
->getValue('cctags_cctid');
$conn
->update('cctags')
->fields(array(
'name' => $form_state
->getValue('cctags_name'),
'block' => $form_state
->getValue('block'),
'block_id' => 'cctagsblock_' . $id,
'page' => $form_state
->getValue('page'),
'page_title' => $form_state
->getValue('page_title'),
'page_path' => $form_state
->getValue('page_path'),
'page_level' => $form_state
->getValue('page_level'),
'page_amount' => $form_state
->getValue('page_amount'),
'page_sort' => $form_state
->getValue('page_sort'),
'page_mode' => $form_state
->getValue('page_mode'),
'page_vocname' => $form_state
->getValue('page_vocname'),
'page_extra_class' => $form_state
->getValue('page_extra_class'),
'item_data' => serialize($form_state
->getValue('vocabulary_table')),
))
->condition('cctid', $id)
->execute();
if ($form_state
->getValue('block')) {
$values = array(
// A unique ID for the block instance.
'id' => 'cctagsblock_' . $id,
// The plugin block id as defined in the class.
'plugin' => 'cctags_block',
// The machine name of the theme region.
'region' => 'content',
'settings' => array(
'label' => 'Cctags',
'tags' => 40,
'tags_more' => 1,
'tags_sort' => 'title,asc',
'level' => 6,
'extra_class' => '',
),
// The machine name of the theme.
'theme' => $this
->config('system.theme')
->get('default'),
'visibility' => array(),
'weight' => 100,
);
if (!Block::load('cctagsblock_' . $id)) {
$block = Block::create($values);
$block
->save();
}
}
if ($form_state
->getValue('page')) {
$this->routeBuilder
->rebuild();
}
$form_state
->setRedirect('cctags.settings_form');
}