You are here

function activeedit_form_alter in Javascript Tools 5

Implementation of hook_form_alter().

File

activeedit/activeedit.module, line 13

Code

function activeedit_form_alter($form_id, &$form) {
  if (isset($_REQUEST['activeedit_id']) && isset($_REQUEST['activeedit_type'])) {
    $key = $_REQUEST['activeedit_id'];
    $type = $_REQUEST['activeedit_type'];
    activeedit_node_form_id($form_id, $key);
    $targets = activeedit_get_targets($type, FALSE, TRUE);
    if ($targets[$key] && $form_id == key($targets[$key]['#form'])) {

      // Set initial value of main field based on autocomplete field value.
      // This needs to come here because the render callback comes after form_builder() is called.
      if (isset($_REQUEST['activeedit_transfer']) && $targets[$key]['#transfer_element']) {
        activeedit_set_transfer($form, $targets[$key]['#transfer_element'], $_REQUEST['activeedit_transfer']);
      }
      if (isset($_POST) && $_POST['activeedit_submit']) {
        $form['#submit']['activeedit_render'] = array();
      }

      // Putting the #pre_render here will cover both initial form rendering before submit and failed
      // validation after submit.
      $form['#pre_render'][] = 'activeedit_render';
    }
  }
}