2

I have the following code (part of a module):

function whm_ui_edit_account_form($form, &$form_state, $account) {

  $res = whm_account_info($account);
  $account_data = $res[0];
  $current_state = array('values' => array(
    'user' => $account_data['user'],
    'domain' => $account_data['domain'],
    'email' => $account_data['email'],
    'plan' => $account_data['plan'],
  ));
  $form_state['values'] = array_merge($current_state['values'], $form_state['post']);

  $form = _whm_ui_account_form($form_state);
  $form['account']['password'] = array(
    '#type' => 'fieldset',
    '#title' => t('Change Password'),
    '#description' => t('Enter values here <b>ONLY</b> if you want to change this account\'s password.'),
    '#collapsible' => TRUE,
    '#collapsed' => empty($form_state['values']['pwd1']) && empty($form_state['values']['pwd2']),
  );
  $form['account']['password']['pwd1'] = $form['account']['pwd1'];
  $form['account']['password']['pwd1']['#required'] = FALSE;
  $form['account']['password']['pwd2'] = $form['account']['pwd2'];
  $form['account']['password']['pwd2']['#required'] = FALSE;
  unset($form['account']['pwd1']);
  unset($form['account']['pwd2']);
  unset($form['account']['email']);
  unset($form['account']['plan']);

  $form['current_user'] = array(
    '#type' => 'hidden',
    '#default_value' => $current_state['values']['user'],
    '#required' => TRUE,
  );
  $form['current_domain'] = array(
    '#type' => 'hidden',
    '#default_value' => $current_state['values']['domain'],
    '#required' => TRUE,
  );
  return $form;
}

The $form_state['post'] no longer exists in D7 (I'm porting an old module) and perhaps I'm insanely tired or just out of my depth :-p but I can't find a suitable replacement. The function is essentially looking to merge existing information with the information given in the form before submitting (I think).

Any assistance or if anyone can point me to an alternative to the post value being used previously it would be appreciated.

3
  • Have you looked at $form_state['input']?
    – Jimajamma
    Commented Aug 11, 2013 at 22:15
  • I haven't but I'll look into it and see what the effect is.
    – MJCO
    Commented Aug 12, 2013 at 17:42
  • That did it JimaJamma - post that as an answer and I'll mark it as such.
    – MJCO
    Commented Aug 12, 2013 at 18:39

1 Answer 1

0

$form_state['post'] in Drupal 6 contains the values of the $_POST global, and a quick look at Drupal 7 shows that when accessing a form via the post method, $form_state['input'] will contain that same array. Side note: if it is accessed via the get method, this will contain $_GET.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.