Drupal配置表单texarea中的所见即所得编辑器

Drupal配置表单texarea中的所见即所得编辑器,drupal,configuration,forms,textarea,wysiwyg,Drupal,Configuration,Forms,Textarea,Wysiwyg,是否可以在TexsiWYG区域使用所见即所得编辑器 对于Drupal站点配置表单(系统设置表单) 这就是现在配置的编码方式 $form['my_module_text_bottom'] = array( '#type' => 'textarea', '#title' => t('Some text'), '#default_value' => variable_get('my_module_text_bottom', 'This is configura

是否可以在TexsiWYG区域使用所见即所得编辑器 对于Drupal站点配置表单(系统设置表单)

这就是现在配置的编码方式

$form['my_module_text_bottom'] = array(
    '#type' => 'textarea',
    '#title' => t('Some text'),
    '#default_value' => variable_get('my_module_text_bottom', 'This is configurable text found in the module configuration.'),
    '#size' => 1024,
    '#maxlength' => 1024,
    '#description' => t("Some text."),
    '#required' => TRUE,
  );
  return system_settings_form($form);

WYSIWYG或CKEditor模块应该能够做到这一点。

我一直在搜索这个问题大约6个小时,最后我找到了原因,对于自定义文本区域字段,您必须添加此行,以使用默认输入格式(完整HTML):

$form['format']=filter_form()

如果在字段集中使用此表单元素,则必须包括此字段集:

$form['generation-instructions']['format']=filter_form()


我希望这将对您有所帮助

我发现这个问题类似于:

其中一个答案指向drupal.org页面:

它提供了“format”数组键和filter_form()的相当详细的示例,还描述了在表单有多个文本区域时如何使用它

这里给出的方法不适用于Drupal7

我遇到了类似的情况,我下载并安装了CKEditor,它在编辑内容节点时显示,但没有在模块的配置表单上显示textarea

就在这里

对于D7:

<?php
  // Retrieve the default values for 'value' and 'format', if not readily
  // available through other means:
  $defaults = array(
    'value' => '',
    'format' => filter_default_format(),
  );
  $my_richtext_field = variable_get('my_richtext_field', $defaults);

  // Just construct a regular #type 'text_format' form element:
  $form['my_richtext_field'] = array(
    '#type' => 'text_format',
    '#title' => t('My richtext field'),
    '#default_value' => $my_richtext_field['value'],
    '#format' => $my_richtext_field['format'],
  );
?>

对于D6:

<?php
  // Your saved or new data is supposed to have a value and a format. Just like
  // $node has a $node->body and $node->format. May also come from a
  // variable_get('mymodule_admin_setting', array('value' => '', 'format' => NULL));
  $mydata = mymodule_data_load();

  $form['myfield']['mytextarea'] = array(
    '#type' => 'textarea',
    '#title' => t('My textarea'),
    '#default_value' => $mydata->value,
  );
  $form['myfield']['format'] = filter_form($mydata->format);
?>


我个人喜欢CKEditor;您可以下载并安装该模块,然后从官方网站下载CKEditor库并将其放置在正确的文件夹中。这是一个更好的答案,因为如果没有这段代码,WYSIWYG模块将无法完成任何事情。