Set default input filter for particular form item

Events happening in the community are now at Drupal community events on www.drupal.org.
Posted by lsiden on February 28, 2011 at 11:32pm

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

Posted by lsiden on March 1, 2011 at 3:13am

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

Posted by sstacks on April 19, 2013 at 10:19pm

Using hook_form_alter in template.php:

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

If it's a hand-crafted form,

Posted by vkareh on March 1, 2011 at 3:50am

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:

AltStyle によって変換されたページ (->オリジナル) /