During development of my extension of contact forms (see http://drupal.org/node/853744) I found some code that can interfere with other modules using hook_form_alter.

    global $user;
    if ($user->uid) {
      $form['copy'] = array(
        '#type'   => 'checkbox',
        '#title'  => t('Send yourself a copy.'),
        '#weight' => $i,
      );
    }

    $form['submit'] = array(
      '#type'   => 'submit',
      '#value'  => t('Send e-mail'),
      '#weight' => $i + 1,
    );

A better and simpeler way to change the weight is:

    if (array_key_exists('copy', $form)) {
      $form['copy']['#weight'] = $i + 1;
    }
    $form['submit']['#weight'] = $i + 1;

I hope the D6 module will have a stable version in the near future.

Comments

manuel.adan’s picture

Status: Active » Needs review
Tor Arne Thune’s picture

Title: Code optimisation » Explicitly set value of #weight instead of replacing entire array
Category: feature » task
Status: Needs review » Patch (to be ported)

This was fixed during the module port to D7. Could easily be backported to the D6 version.

oadaeh’s picture

Issue summary: View changes
Status: Patch (to be ported) » Closed (outdated)

I'm closing this as it is for a branch that is no longer supported.