Flipkart

Thursday, July 21, 2011

Add Input Format to Textarea in Custom Module

To apply input formats to any textarea in our custom module forms we can use below code:

$form['format'] = filter_form(FILTER_FORMAT_DEFAULT);

example:
$form['body'] = array(
    '#type' => 'textarea',
    '#title' => t('Body'),
    '#default_value' => 'sample',
  );
$form['format'] = filter_form(FILTER_FORMAT_DEFAULT);


If you are creating Textarea under Fieldset then we have to apply filedset name to that format element as array like:

$form['filedset']['format'] = filter_form(FILTER_FORMAT_DEFAULT);

No comments:

Post a Comment