function apigee_edge_form_user_form_alter in Apigee Edge 8
Implements hook_form_FORM_ID_alter().
File
- ./
apigee_edge.module, line 697 - Copyright 2018 Google Inc.
Code
function apigee_edge_form_user_form_alter(&$form, FormStateInterface $form_state, $form_id) {
// Only alter the user edit form.
if ($form_id === 'user_register_form') {
return;
}
// The email field should be always required because it is required on
// Apigee Edge.
$form['account']['mail']['#required'] = TRUE;
$user = \Drupal::currentUser();
// Make the same information available here as on user_register_form.
// @see \Drupal\user\RegisterForm::form()
$form['administer_users'] = [
'#type' => 'value',
'#value' => $user
->hasPermission('administer users'),
];
// Add the API connection custom validation callback to the beginning of the
// chain apigee_edge_module_implements_alter() ensures that form_alter hook is
// called in the last time.
$validation_functions[] = 'apigee_edge_form_user_form_api_connection_validate';
// Add email custom validation callback to the chain immediately after the API
// connection validation apigee_edge_module_implements_alter() ensures that
// form_alter hook is called in the last time.
$validation_functions[] = 'apigee_edge_form_user_form_developer_email_validate';
$form['#validate'] = array_merge($validation_functions, $form['#validate']);
}