public function RemoveViewsCustomTable::validateForm in Views Custom Table 8
Same name and namespace in other branches
- 9.0.x src/Form/RemoveViewsCustomTable.php \Drupal\view_custom_table\Form\RemoveViewsCustomTable::validateForm()
Form validation 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 FormBase::validateForm
File
- src/
Form/ RemoveViewsCustomTable.php, line 90
Class
- RemoveViewsCustomTable
- Add views custom table form.
Namespace
Drupal\view_custom_table\FormCode
public function validateForm(array &$form, FormStateInterface $form_state) {
$table_name = $form_state
->getValue('table_name');
$config = $this->config
->getRawData();
if (isset($config[$table_name])) {
$table_dependancy = [];
foreach ($config as $table => $table_information) {
if (strpos($table_information['column_relations'], $table_name) !== FALSE) {
$table_dependancy[] = $table;
}
}
if (!empty($table_dependancy)) {
$dependent_table_names = implode(', ', $table_dependancy);
$form_state
->setErrorByName('table_name', $this
->t("@table can not be deletede because @dependent_tables are dependent on @table.", [
'@table' => $table_name,
'@dependent_tables' => $dependent_table_names,
]));
}
}
}