Form API: #type textarea and plain-text format?

jeff00seattle - May 12, 2009 - 19:35

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

Found answer...

jeff00seattle - May 12, 2009 - 21:21

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:

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

Cheers

Jeff in Seattle

Jeff in Seattle

form_alter solution

revnoah - June 5, 2009 - 17:34

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.

<?php
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.

Better to use #wysiwyg

mErilainen - June 30, 2009 - 13:14

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?

 
 

Drupal is a registered trademark of Dries Buytaert.