You are here

function profile_field_form_submit in Drupal 7

Same name and namespace in other branches
  1. 4 modules/profile.module \profile_field_form_submit()
  2. 5 modules/profile/profile.module \profile_field_form_submit()
  3. 6 modules/profile/profile.admin.inc \profile_field_form_submit()

Process profile_field_form submissions.

File

modules/profile/profile.admin.inc, line 363
Administrative page callbacks for the profile module.

Code

function profile_field_form_submit($form, &$form_state) {
  if (!isset($form_state['values']['options'])) {
    $form_state['values']['options'] = '';
  }
  if (!isset($form_state['values']['page'])) {
    $form_state['values']['page'] = '';
  }

  // Remove all elements that are not profile_field columns.
  $values = array_intersect_key($form_state['values'], array_flip(array(
    'type',
    'category',
    'title',
    'name',
    'explanation',
    'visibility',
    'page',
    'weight',
    'autocomplete',
    'required',
    'register',
    'options',
  )));
  if (!isset($form_state['values']['fid'])) {
    db_insert('profile_field')
      ->fields($values)
      ->execute();
    drupal_set_message(t('The field has been created.'));
    watchdog('profile', 'Profile field %field added under category %category.', array(
      '%field' => $form_state['values']['title'],
      '%category' => $form_state['values']['category'],
    ), WATCHDOG_NOTICE, l(t('view'), 'admin/config/people/profile'));
  }
  else {
    db_update('profile_field')
      ->fields($values)
      ->condition('fid', $form_state['values']['fid'])
      ->execute();
    drupal_set_message(t('The field has been updated.'));
  }
  cache_clear_all();
  menu_rebuild();
  $form_state['redirect'] = 'admin/config/people/profile';
  return;
}