public function BaseFieldConfigFromBase::validateForm in Apigee Edge 8
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/ BaseFieldConfigFromBase.php, line 120
Class
- BaseFieldConfigFromBase
- Base form for configuring base fields on Apigee Edge entities.
Namespace
Drupal\apigee_edge\FormCode
public function validateForm(array &$form, FormStateInterface $form_state) {
parent::validateForm($form, $form_state);
/** @var \Drupal\Core\Entity\Display\EntityFormDisplayInterface $display */
$display = $this->entityTypeManager
->getStorage('entity_form_display')
->load("{$this->entityType()}.{$this->entityType()}.default");
if ($display) {
foreach ($form_state
->getValue('table') as $name => $data) {
$component = $display
->getComponent($name);
if ($data['required'] && !($component && $component['region'] !== 'hidden')) {
$form_state
->setError($form['table'][$name]['required'], $this
->t('%field-name is hidden on the default form display.', [
'%field-name' => $form['table'][$name]['name']['#markup'],
]));
}
}
}
}