Attach WYSIWYG to custom Drupal form
I have a custom module implementing a syst开发者_运维技巧em settings form, and I would like to attach WYSIWYG to the text area field. However, nothing I am doing is having much affect. I am using the latest WYSIWYG module with CKEditor. There are no JS errors. All I get on the screen is a plain text area.
Code:
$form['mymodule'] = array(
'#type' => 'fieldset',
'#title' => t('Settings'),
);
$form['mymodule']['email_content'] = array(
'#title' => 'Email Content',
'#type' => 'textarea',
'#description' => t('The content of the message that is emailed to the user when a license key is assigned. You can use [user_fullname] and [user_license_key] to substitute for the user name and license key, respectively.'),
'#default_value' => variable_get('mymodule_email_content', ''),
);
$form['mymodule']['format'] = filter_form(2);
All this seems to do is provide a filter selection. Got that from this page: http://drupal.org/node/358316. Even when you pick a format, the WYSIWYG does not load.
What I want to do is simply have the form present the WYSIWYG without having to make a format selection. How can I trigger it to load on the textarea in the Form API?
You need to add a subarray for the wysiwyg thing
$form['mymodule']['foo']['email_content'] = array( '#title' => 'Email Content', . . .
$form['mymodule']['foo']['format'] = filter_form(2);
Maybe you can hide the filter selection box using css?
精彩评论