[development] Programmatically update allowed_html filter settings

Cameron B. Prince cplists at teslauniverse.com
Tue Mar 13 07:28:19 UTC 2012


Hi,

The baseline module I'm developing needs to add the <span> tag to the
allowed_html value for the filtered_html text filter when enabled.

I've searched the core modules, the standard installation profile,
Drupal.org and Google, but I haven't been able to find an example of the
proper way to do this in a module.install's hook_enable().

I assume I should use filter_format_save() and tried the following:

filter_format_save('filtered_html', 'filter_html', 1, 1, array(
  'settings' => array(
    'allowed_html' => '<a> <em> <strong> <cite> <blockquote> <code> <ul>
<ol> <li> <dl> <dt> <dd> <span>'
    )
  )
);

This resulted in "PDOException: SQLSTATE[23000]: Integrity constraint
violation: 1048 Column 'format' cannot be null" which I don't understand
because the first argument to filter_format_save() is the format.

Could someone point me in the right direction?

Thanks,
Cameron




More information about the development mailing list