Set default input filter for particular form item

Events happening in the community are now at Drupal community events on www.drupal.org.
lsiden's picture

I thought there was a way to configure particular form items (usually textareas) to use a particular input filter by default that may be different than the global default set in /admin/settings/filters. Does anyone remember that or am I imagining things in my coding delirium?

Comments

Answered my own question

lsiden's picture

The way that worked for me is to use hook_form_alter(). The format option will be in $form[$field_name]['format'].

This is how I did it in Drupal 7

sstacks's picture

Using hook_form_alter in template.php:

$form['field_name'] = array(
      '#type' => 'text_format',
      '#format' => 'filtered_html',
    ); 

If it's a hand-crafted form,

vkareh's picture

If it's a hand-crafted form, you don't need a hook_form_alter, since you can just set the format flag manually. For CCK fields, you can allow input filter by selecting Filtered text (user selects input format) under Text processing.

Now, if you need to force an input that's different from the default, you're looking at the Better Formats module.

Jackson, Michigan

Group organizers

Group notifications

This group offers an RSS feed. Or subscribe to these personalized, sitewide feeds: