public function EditTableRelations::submitForm in Views Custom Table 8
Same name and namespace in other branches
- 9.0.x src/Form/EditTableRelations.php \Drupal\view_custom_table\Form\EditTableRelations::submitForm()
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/ EditTableRelations.php, line 162
Class
- EditTableRelations
- Edit views custom table form.
Namespace
Drupal\view_custom_table\FormCode
public function submitForm(array &$form, FormStateInterface $form_state) {
$table_name = $form_state
->getValue('table_name');
$relations = $form_state
->getValue('columns');
$column_relations = [];
foreach ($relations as $relation) {
if ($relation['entity'] != 'none') {
$column_relations[$relation['field']] = $relation['entity'];
}
}
$serialize_relations = serialize($column_relations);
$this->configEditable
->set($table_name . '.column_relations', $serialize_relations);
$result = $this->configEditable
->save();
if ($result) {
drupal_set_message($this
->t('@table relations are updated.', [
'@table' => $table_name,
]));
}
else {
drupal_set_message($this
->t('Could not update @table data, please check log messages for error.', [
'@table' => $table_name,
]), 'error');
}
$form_state
->setRedirect('view_custom_table.customtable');
}