You are here

function role_delegation_user_form_builder in Role Delegation 8

Entity builder for the user form with empty field value for "role_change".

See also

role_delegation_form_alter()

1 string reference to 'role_delegation_user_form_builder'
role_delegation_form_user_form_alter in ./role_delegation.module
Implements hook_form_BASE_FORM_ID_alter().

File

./role_delegation.module, line 164
Allows admins to grant roles the authority to assign selected roles to users.

Code

function role_delegation_user_form_builder($entity_type, UserInterface $user, &$form, FormStateInterface $form_state) {

  // If the user has no access to the "role_change" field, then the form will
  // submit an empty array for the field, which will make later processing think
  // it was intentional. Set it to the empty field value to correct this.
  if (!isset($form['role_change']['#access']) || !$form['role_change']['#access']) {
    $user
      ->set('role_change', DelegatableRoles::$emptyFieldValue);
  }
}