You are here

function _linkit_build_role_associate_form_fields in Linkit 7.2

Append role form elements to the settings form.

1 call to _linkit_build_role_associate_form_fields()
linkit_profiles_export_ui_form in plugins/export_ui/linkit_profiles.inc
Generate a profile form.

File

plugins/export_ui/linkit_profiles.inc, line 279

Code

function _linkit_build_role_associate_form_fields(&$form, $profile) {
  $roles = user_roles();
  $assiged_roles = _linkit_get_associated_roles($profile);
  foreach ($roles as $role_id => $role_name) {
    $form['roles'][$role_id] = array(
      '#type' => 'checkbox',
      '#title' => $role_name,
      '#default_value' => isset($profile->role_rids[$role_id]) ? $profile->role_rids[$role_id] : FALSE,
    );

    // Disable roles thats already associated.
    if (in_array($role_id, array_keys($assiged_roles))) {
      $form['roles'][$role_id]['#disabled'] = TRUE;
      $form['roles'][$role_id]['#description'] = t('This role is already in use by the %name profile', array(
        '%name' => $assiged_roles[$role_id],
      ));
    }
  }
}