filter_form

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

modules/filter/filter.module, строка 485

Версии
5 – 6
filter_form($value = FILTER_FORMAT_DEFAULT, $weight = NULL, $parents = array('format'))

Generate a selector for choosing a format in a form.

See also

filter_form_validate()

Параметры

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

$weight The weight of the input format.

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

Возвращаемое значение

HTML for the form element.

Связанные темы

▾ 4 функции вызывают filter_form()

block_box_form in modules/block/block.module
Определяет пользовательскую блоковую форму.
comment_form in modules/comment/comment.module
Создаёт базовую форму для комментирования, которая будет добавлена к странице с нодой или отображена на отдельной странице.
node_body_field in modules/node/node.pages.inc
Return a node body field, with format and teaser.
user_edit_form in modules/user/user.module

Код

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

  $extra = theme('filter_tips_more_info');

  if (count($formats) > 1) {
    $form = array(
      '#type' => 'fieldset',
      '#title' => t('Input format'),
      '#collapsible' => TRUE,
      '#collapsed' => TRUE,
      '#weight' => $weight,
      '#element_validate' => array('filter_form_validate'),
    );
    // Multiple formats available: display radio buttons with tips.
    foreach ($formats as $format) {
      // Generate the parents as the autogenerator does, so we will have a
      // unique id for each radio button.
      $parents_for_id = array_merge($parents, array($format->format));
      $form[$format->format] = array(
        '#type' => 'radio',
        '#title' => $format->name,
        '#default_value' => $value,
        '#return_value' => $format->format,
        '#parents' => $parents,
        '#description' => theme('filter_tips', _filter_tips($format->format, FALSE)),
        '#id' => form_clean_id('edit-'. implode('-', $parents_for_id)),
      );
    }
  }
  else {
    // Only one format available: use a hidden form item and only show tips.
    $format = array_shift($formats);
    $form[$format->format] = array('#type' => 'value', '#value' => $format->format, '#parents' => $parents);
    $tips = _filter_tips(variable_get('filter_default_format', 1), FALSE);
    $form['format']['guidelines'] = array(
      '#title' => t('Formatting guidelines'),
      '#value' => theme('filter_tips', $tips, FALSE, $extra),
    );
  }
  $form[] = array('#value' => $extra);
  return $form;
}
?>
Войдите или зарегистрируйтесь, чтобы получить возможность отправлять комментарии

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