You are here

function patterns_forms_get_formats_selector in Patterns 7.2

Same name and namespace in other branches
  1. 7 includes/forms/forms.inc \patterns_forms_get_formats_selector()

Builds a HTML select element with all the currently available patterns formats.

Parameters

array $form (optional) If specified, the select form is appended: here. Default array().

mixed $default (optional) The default value for the selector.: Default PATTERNS_FORMAT_UNKNOWN.

bool $unknown (optional) If TRUE PATTERNS_FORMAT_UNKNOWN is added: to the 'available' formats. Default TRUE.

Return value

array $form The form containing the select element.

7 calls to patterns_forms_get_formats_selector()
patterns_edit in includes/forms/editor.inc
Form constructor for editing a pattern. TODO:params
patterns_export_page1 in patterns_export/patterns_export.module
patterns_import_file in includes/forms/import.inc
Display the import pattern file form
patterns_import_source in includes/forms/import.inc
Form constructor for the Pattern import form.
patterns_import_url in includes/forms/import.inc
Display the import pattern url form

... See full list

File

includes/forms/forms.inc, line 124

Code

function patterns_forms_get_formats_selector(&$form = array(), $default = PATTERNS_FORMAT_UNKNOWN, $descr = NULL, $unknown = TRUE) {
  $descr = is_null($descr) ? t('Pattern will be validated and run against this format.') : t($descr);
  $formats = $unknown ? array(
    PATTERNS_FORMAT_UNKNOWN => PATTERNS_FORMAT_UNKNOWN,
  ) : array();
  $available_formats = patterns_parser_get_formats();
  if (!empty($available_formats)) {
    $formats = array_merge($formats, array_combine($available_formats, $available_formats));
  }
  $form['format'] = array(
    '#type' => 'select',
    '#title' => t('Pattern syntax'),
    '#options' => $formats,
    '#default_value' => $default,
    '#description' => $descr,
  );
  return $form;
}