I want to display a simple table under a form field as part of the help text for that field (file field to be exact). Am I being totally mental or is there really no easy way of changing the allowed html tags for this text area? At the moment I have displayed:
Instructions to present to the user below this field on the editing form.
Allowed HTML tags: a b big code del em i ins pre q small span strong sub sup tt ol ul li p br img
If there is no easy way, what is the next easiest way of doing it?
UPDATE:
Clive came up with a great way of doing it below with a custom module. You can also add to this using ctools to make the help text collapsible as follows:
// Implement hook_field_widget_form_alter()
function MYMODULE_field_widget_form_alter(&$element, &$form_state, &$context) {
// If some condition is matched based on the element provided...
if (isset($element[0]) && $element[0]['#field_name'] == 'field_test') {
// Alter the description using your more permissive set of tags
$reworked = filter_xss($context['instance']['description'], _MYMODULE_field_filter_xss_allowed_tags());
$element[0]['#description'] = theme('ctools_collapsible', array('handle' => 'Help text', 'content' => $reworked, 'collapsed' => TRUE));
}
}
// Provide a more permissive set of tags to be used with filter_xss()
function _MYMODULE_field_filter_xss_allowed_tags() {
// Merge the new set of allowed tags with the less permissive defaults
$new_tags = array('table', 'thead', 'tbody', 'tfoot', 'tr', 'th', 'td');
return array_merge(_field_filter_xss_allowed_tags(), $new_tags);
}