Trigger WYSIWYG editor in Drupal Form API


/ Published in: PHP
Save to your folder(s)

The trick is having a "format" key for the textarea and using filter_form().

Use two elements with the same parent; the textarea element and an element with the "format" key. (important!).

Example below.


Copy this code and paste it in your HTML
  1. $form['some_wrapper'] = array(
  2. '#tree' => TRUE,
  3. 'text' => array(
  4. '#title' => 'Text',
  5. '#type' => 'textarea',
  6. '#default_value' => 'Default Text',
  7. ),
  8. 'format' => filter_form($value = FILTER_FORMAT_DEFAULT, NULL, array('format'))
  9. );

URL: http://api.drupal.org/api/function/filter_form/6

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.