You are here

function patterns_quickrun in Patterns 7

Same name and namespace in other branches
  1. 7.2 includes/forms/quickrun.inc \patterns_quickrun()

Form constructor for the Quick Run form.

See also

patterns_quickrun_submit()

2 string references to 'patterns_quickrun'
patterns_editor in includes/forms/editor.inc
Builds up a pattern editing environment. Loads additional javascript libraries, and supplies AJAX validation on the fly.
patterns_menu in ./patterns.module
Implements hook_menu().

File

includes/forms/quickrun.inc, line 13
Functions, forms related to the Patterns editor.

Code

function patterns_quickrun($form, &$form_state) {
  $form = array();
  if (!patterns_parser_ready()) {
    return $form;
  }
  $content = '';
  $text = t('The quick run mode should be used only in development environment, for testing, or if you really know what you are doing.');
  patterns_forms_add_page_header($form, 'Important!', $text);
  $options_mode = array(
    'extend' => 'Extend',
    'runover' => 'Run-Over',
  );

  // Add the execution options
  $form = patterns_forms_get_execution_options($form);
  $form['validation_result'] = array(
    '#markup' => 'This pattern has not been validated yet.',
    '#prefix' => '<div id="validation_result">',
    '#suffix' => '</div>',
  );
  $form = patterns_forms_get_formats_selector($form);

  //Set the field as required for the quickrun case
  $form['format']['#required'] = TRUE;
  $form['content'] = array(
    '#type' => 'textarea',
    '#title' => t('Pattern\'s code'),
    '#rows' => 25,
    '#default_value' => $content,
  );
  $form['submit'] = array(
    '#type' => 'submit',
    '#value' => t('Run'),
  );
  $form['validate'] = array(
    '#prefix' => '<span style=\'margin-right:10px\'>',
    '#markup' => "<a href='#' id='validate_pattern'>" . t('Validate') . "</a>",
    '#suffix' => '</span> ',
  );
  $form['cancel'] = array(
    '#markup' => l(t('Back'), 'admin/patterns'),
  );
  return $form;
}