You are here

function user_badges_change_form in User Badges 6.2

Same name and namespace in other branches
  1. 6 user_badges.module \user_badges_change_form()
  2. 7.4 user_badges.module \user_badges_change_form()
  3. 7 user_badges.module \user_badges_change_form()
  4. 7.2 user_badges.module \user_badges_change_form()
  5. 7.3 user_badges.module \user_badges_change_form()

Form to change badges of a user

1 string reference to 'user_badges_change_form'
user_badges_page in ./user_badges.module
Define the page on user/uid/badges/edit.

File

./user_badges.module, line 577
@brief User Badges module file

Code

function user_badges_change_form(&$form_state, $account) {
  $form = array();
  $form['uid'] = array(
    '#type' => 'value',
    '#value' => $account->uid,
  );
  $form['add'] = array(
    '#type' => 'fieldset',
    '#title' => t('Add Badges'),
    '#weight' => 3,
    '#collapsible' => TRUE,
    '#collapsed' => FALSE,
  );
  for ($i = 1; $i <= 5; $i++) {
    $form['add']['add' . $i] = array(
      '#type' => 'textfield',
      '#title' => t('New Badge !number', array(
        '!number' => $i,
      )),
      '#size' => 40,
      '#maxlength' => 255,
      '#autocomplete_path' => 'user_badges/autocomplete',
    );
  }
  if (count($account->badges_all)) {
    $form['remove'] = array(
      '#type' => 'fieldset',
      '#title' => t('Remove Badges'),
      '#weight' => 5,
      '#collapsible' => TRUE,
      '#collapsed' => FALSE,
    );
    foreach ($account->badges_all as $badge) {
      $form['remove'][$badge->bid] = array(
        '#type' => 'checkbox',
        '#title' => theme('user_badge', $badge, $account),
        '#return_value' => 1,
        '#default_value' => 0,
        '#description' => check_plain($badge->name),
      );
    }
  }
  $form['submit'] = array(
    '#type' => 'submit',
    '#value' => t('Update Badges'),
    '#weight' => 10,
  );
  return $form;
}