Developer info (D7+) - Creating a text field with Wysiwyg enabled

You are browsing documentation for an older version of Drupal, which is not supported any longer, and the information may not be correct. See current documentation for Contributed modules

Drupal 7 introduces the form element #type text_format, which is a text-format-enabled version of a textarea.

  // 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'],
  );

Creating a custom CKEditor plugin

Short guide to adding your own CKEditor plugin using wysiwyg hooks.

Guide maintainers

pillarsdotnet's picture