filter_form

  1. drupal
    1. drupal6
    2. drupal7
Versionen
drupal6 – drupal7 filter_form($value = FILTER_FORMAT_DEFAULT, $weight = NULL, $parents = array('format'))

Generate a selector for choosing a format in a form.

Übergabeparameter

$value The ID of the format that is currently selected.

$weight The weight of the text format.

$parents Required when defining multiple text formats on a single node or having a different parent than 'format'.

Rückgabewert

HTML for the form element.

Verwandte Themen

▾ 3 functions call filter_form()

form_process_text_format in includes/form.inc
Add text format selector to text elements with the #text_format property.
text_textarea_process in modules/field/modules/text/text.module
Process an individual element.
text_textfield_process in modules/field/modules/text/text.module
Process an individual element.

Code

modules/filter/filter.module, line 480

<?php
function filter_form($value = FILTER_FORMAT_DEFAULT, $weight = NULL, $parents = array('format')) {
  $value = filter_resolve_format($value);
  $formats = filter_formats();

  drupal_add_js('misc/form.js');
  drupal_add_css(drupal_get_path('module', 'filter') . '/filter.css');
  $element_id = form_clean_id('edit-' . implode('-', $parents));

  $form = array(
    '#type' => 'fieldset',
    '#weight' => $weight,
    '#attributes' => array('class' => 'filter-wrapper'),
  );
  $form['format_guidelines'] = array(
    '#prefix' => '<div id="' . $element_id . '-guidelines" class="filter-guidelines">',
    '#suffix' => '</div>',
    '#weight' => 2,
  );
  foreach ($formats as $format) {
    $options[$format->format] = $format->name;
    $form['format_guidelines'][$format->format] = array(
      '#markup' => theme('filter_guidelines', $format),
    );
  }
  $form['format'] = array(
    '#type' => 'select',
    '#title' => t('Text format'),
    '#options' => $options,
    '#default_value' => $value,
    '#parents' => $parents,
    '#access' => count($formats) > 1,
    '#id' => $element_id,
    '#attributes' => array('class' => 'filter-list'),
  );
  $form['format_help'] = array(
    '#prefix' => '<div id="' . $element_id . '-help" class="filter-help">',
    '#markup' => theme('filter_tips_more_info'),
    '#suffix' => '</div>',
    '#weight' => 1,
  );

  return $form;
}
?>

Kommentare

Kommentar hinzufügen

Der Inhalt dieses Feldes wird nicht öffentlich zugänglich angezeigt.
  • Internet- und E-Mail-Adressen werden automatisch umgewandelt.
  • Zulässige HTML-Tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd>
  • Zeilen und Absätze werden automatisch erzeugt.

Weitere Informationen über Formatierungsoptionen

Kommentar hinzufügen

Der Inhalt dieses Feldes wird nicht öffentlich zugänglich angezeigt.
  • Internet- und E-Mail-Adressen werden automatisch umgewandelt.
  • Zulässige HTML-Tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd>
  • Zeilen und Absätze werden automatisch erzeugt.

Weitere Informationen über Formatierungsoptionen