Hi

Is there a way to declare a form element of #type textarea to use only plain-text editor and NOT present fckeditor?

The styling is currently as follows by default when using #type textarea, because I do have fckeditor module installed:

<textarea class="form-textarea resizable fckeditor fckeditor-processed textarea-processed" id="edit-body" name="body" rows="2" cols="60" style="display: block;"/>

Thanks

Jeff in Seattle

Comments

jeff00seattle’s picture

Not documented within Form API reference:
http://api.drupal.org/api/file/developer/topics/forms_api_reference.html/6

Set form element with: '#wysiwyg' => false, and this will disable any WYSIWYG editor like FckEditor.

For example:

    $form['body'] = array(
      '#type' => 'textarea',
      '#title' => $title,
      '#wysiwyg' => false,
    );

Cheers

Jeff in Seattle

revnoah’s picture

I needed to remove TinyMCE from the comments field. I couldn't get the above solution to work, but I had a custom module set up with a form_alter function.

function my_module_form_alter($form_id, &$form) {
  if ($form_id['#id'] == 'comment-form') {
  $form_id['comment_filter']['format'] = array();
  }
}

I've posted more details and discussion on why I chose this method on my blog.

merilainen’s picture

I tried your method, but then the form got too wide and couldn't fit into my panel. Instead I used this

<?php
function alterforms_form_alter(&$form, $form_state, $form_id) {
  switch ($form_id) {
  case 'comment_form':
    $form['#wysiwyg'] = false;
  break;
}
?>

I tried to this by overriding in template.php but that didn't work.

UPDATE:
This didn't work after all, it was just not loading the editor for some other reason. Is there a way to disable wysiwyg the way I tried, not just clearing the array completely?

jebernier’s picture

Did u find a solution to this.

The textarea in my form shows CKEditor fields and I just want it to be a plain text area box.

Pulling my hair out over this one.

John
jebernier@gmail.com

taiger’s picture

For Drupal 8, you need to change "textarea" to "text_format".

For example, this changes the system email to use html email (though you still need to set up Swiftmailer or equivalent to actually send it).

 

<?php

use Drupal\Core\Form\FormStateInterface;

/**
 * Implements hook_form_FORM_ID_alter().
 *
 * Change plaintext email textfields to WYSIWYG fields.
 */
function my_module_form_user_admin_settings_alter(&$form, FormStateInterface $form_state) {

  $form['email_admin_created']['user_mail_register_admin_created_body']['#type'] = 'text_format';
  $form['email_admin_created']['user_mail_register_admin_created_body']['#format'] = 'full_html';

}