Changing Allowed HTML tags: @tags for help text input field 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(&amp;$element, &amp;$form_state, &amp;$context) {
  // If some condition is matched based on the element provided...
  if (isset($element[0]) &amp;&amp; $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' =&gt; 'Help text', 'content' =&gt; $reworked, 'collapsed' =&gt; 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);
}
There isn't an easy way to do it really, the list of allowed tags is hard coded into the _field_filter_xss_allowed_tags() function. 

This is in turn called by field_filter_xss(), not when the data is saved to the database but rather when it's displayed in field_default_form().

Fortunately there is a way but it'll take a small custom module to do it. You're basically looking to implement a form alter hook for the field's widget form and set the element's description to use filter_xss() with a more permissive set of tags. 

Something along these lines:

// Implement hook_field_widget_form_alter()
function MYMODULE_field_widget_form_alter(&amp;$element, &amp;$form_state, &amp;$context) {
  // If some condition is matched based on the element provided...
  if (isset($element[0]) &amp;&amp; $element[0]['#field_name'] == 'field_test') {
    // Alter the description using your more permissive set of tags
    $element[0]['#description'] = filter_xss($context['instance']['description'], _MYMODULE_field_filter_xss_allowed_tags());
  }
}

// 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);
}


That's based on the premise that you only want to allow the new tags for an element called field_test, obviously if you want to do the same for other fields you'll need to change it to match a different condition. I advise using the excellent dpm() function included in the Devel module to inspect object in your form alter function.

I've just tested the above and it works (I now have a table where my file field description would normally be), it feels a bit like a hack even though it technically sticks to the rules but hopefully it'll get you on the way.