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);
$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