Overrides Drupal\Core\Entity\EntityFormController::validate().
Overrides EntityFormController::validate
public function validate(array $form, array &$form_state) {
$picture_mapping = $this
->getEntity($form_state);
// Only validate on edit.
if (isset($form_state['values']['mappings'])) {
$picture_mapping->mappings = $form_state['values']['mappings'];
// Check if another breakpoint group is selected.
if ($form_state['values']['breakpointGroup'] != $form_state['complete_form']['breakpointGroup']['#default_value']) {
// Remove the mappings.
unset($form_state['values']['mappings']);
}
elseif (!$picture_mapping
->isNew() && !$picture_mapping
->hasMappings()) {
form_set_error('mappings', t('Please select at least one mapping.'));
}
}
}