简体   繁体   中英

Attach WYSIWYG to custom Drupal form

I have a custom module implementing a system 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?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM