1 ajax_example_progressbar.inc ajax_example_progressbar_form($form, &$form_state)

Implements hook_FORMID().

Build a landing-page form for the progress bar example.

See also

https://docs.backdropcms.org/form_api#ajax['progress']

File

modules/examples/ajax_example/ajax_example_progressbar.inc, line 14
Progress bar example.

Code

function ajax_example_progressbar_form($form, &$form_state) {
  $form_state['time'] = REQUEST_TIME;

  // We make a DIV which the progress bar can occupy. You can see this in use
  // in ajax_example_progressbar_callback().
  $form['status'] = array(
    '#markup' => '<div id="progress-status"></div>',
  );

  $form['submit'] = array(
    '#type' => 'submit',
    '#value' => t('Submit'),
    '#ajax' => array(
      // Here we set up our AJAX callback handler.
      'callback' => 'ajax_example_progressbar_callback',
      // Tell FormAPI about our progress bar.
      'progress' => array(
        'type' => 'bar',
        'message' => t('Execute..'),
        // Have the progress bar access this URL path.
        'url' => url('examples/ajax_example/progressbar/progress/' . $form_state['time']),
        // The time interval for the progress bar to check for updates.
        'interval' => 1000,
      ),
    ),
  );

  return $form;
}