You are here

function pcp_form_alter in Profile Complete Percent 6

Same name and namespace in other branches
  1. 5 pcp.module \pcp_form_alter()
  2. 7 pcp.module \pcp_form_alter()

Implementation of hook_form_alter()

File

./pcp.module, line 63
Allows users with valid permissions to tag profile fields created from the profile module as required fields for a users profile to be considered complete.

Code

function pcp_form_alter(&$form, $form_state, $form_id) {
  if ($form_id == 'profile_field_form' && user_access('administer pcp')) {
    $fid = $form['fid']['#value'];
    $tag = TRUE;
    if ($fid) {
      $field_data = pcp_get_tagged_profile_fields($fid);
      if (!$field_data[0]['fid']) {
        $tag = FALSE;
      }
    }
    $form['pcp_settings'] = array(
      '#type' => 'fieldset',
      '#title' => t('PCP Settings'),
      '#weight' => 0,
    );
    $form['pcp_settings']['tag'] = array(
      '#type' => 'checkbox',
      '#title' => t('Make required for PCP module'),
      '#description' => t('Checking this box will tag this field as a required field for completion of the users profile.'),
      '#default_value' => $tag,
    );
    $form['#submit'][] = 'pcp_profile_field_form_submit';
  }
  if ($form_id == 'user_profile_form' && arg(3) != '' && $_GET['fieldname'] != '') {
    $fieldname = 'edit-' . preg_replace("/_/", "-", $_GET['fieldname']);
    drupal_add_js("\n      \$('#" . $fieldname . "').css({\n        'border' : '2px solid red' \n        });\n    ", 'inline', 'footer');
  }
}