public function SourceCsvForm::validateForm in Migrate Tools 8.4
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/ SourceCsvForm.php, line 294
Class
- SourceCsvForm
- Provides an edit form for CSV source plugin column_names configuration.
Namespace
Drupal\migrate_tools\FormCode
public function validateForm(array &$form, FormStateInterface $form_state) {
// Display an error message if two properties have the same source column.
$values = [];
foreach ($this->columnNames as $index => $data) {
$property_name = key($data);
$value = $form_state
->getValue($property_name);
if (in_array($value, $values)) {
$form_state
->setErrorByName($property_name, $this
->t('Source properties can not share the same source column.'));
}
$values[] = $value;
}
}