multipage_form_example_form_alter

Хочешь помочь с переводом? Это очень просто и быстро. Лишь зарегистрируйся, и можешь тут же начать переводить.

developer/examples/multipage_form_example.module, строка 180

Версии
5 – 6
multipage_form_example_form_alter($form_id, &$form)

Implementation of hook_form_alter(). Here, we set up the 'page' field, which keeps track of what stage the form is in.

Код

<?php
function multipage_form_example_form_alter($form_id, &$form) {
  // Make sure it's our multipage form.
  if ($form_id == 'multipage_form_example_node_form') {

    // Determine which page of the multipage form we're on. We don't do
    // any incrementing here - that's something that our #pre_render'er
    // will do when this page of the form has successfully validated.
    $form['page'] = array(
      '#type' => 'hidden',
      '#value' => isset($_POST['edit']['page']) ? $_POST['edit']['page'] : 1,
    );

    // If back button is pressed, back up the form stage, Also, if preview
    // is hit we need to decrement the counter here to keep us on the same page.
    if ($_POST['op'] == t('Back')) {
      $form['page']['#value']--;
    }

    // This modifies the form for validation purposes. once validation is
    // completed, it'll be called one more time (through Drupal's Form API)
    // at which point it'll advance the form to the next page.
    multipage_form_example_pre_render($form_id, $form, FALSE);

    // Here we're augmenting the regular node form validation/submission with
    // some of our own.  Note that these are inside the conditional check for
    // this particular form.
    $form['#validate'] = array_merge($form['#validate'], array('multipage_form_example_custom_validate' => array()));
    $form['#submit'] = array_merge($form['#submit'], array('multipage_form_example_custom_submit' => array()));
  }

  return $form;
}
?>
Войдите или зарегистрируйтесь, чтобы получить возможность отправлять комментарии

Вход в систему