You are here

function _apigee_edge_developer_app_entity_form_display_edit_form_validate in Apigee Edge 8

Extra validation for the entity_form_display.edit form of developer apps.

This makes sure that fields marked as 'required' can't be disabled.

Parameters

array $form: Form array.

Drupal\Core\Form\FormStateInterface $form_state: Form state.

1 string reference to '_apigee_edge_developer_app_entity_form_display_edit_form_validate'
apigee_edge_form_entity_form_display_edit_form_alter in ./apigee_edge.module
Implements hook_form_FORM_ID_alter().

File

./apigee_edge.module, line 569
Copyright 2018 Google Inc.

Code

function _apigee_edge_developer_app_entity_form_display_edit_form_validate(array &$form, FormStateInterface $form_state) {
  $required = \Drupal::config('apigee_edge.developer_app_settings')
    ->get('required_base_fields');
  foreach ($form_state
    ->getValue('fields') as $field_name => $data) {
    if (in_array($field_name, $required) && $data['region'] === 'hidden') {
      $form_state
        ->setError($form['fields'][$field_name], t('%field-name is required.', [
        '%field-name' => $form['fields'][$field_name]['human_name']['#plain_text'],
      ]));
    }
  }
}