diff --git a/modules/ds_extras/ds_extras.module b/modules/ds_extras/ds_extras.module index 6d0665e..339899e 100644 --- a/modules/ds_extras/ds_extras.module +++ b/modules/ds_extras/ds_extras.module @@ -801,6 +801,14 @@ function theme_ds_field_expert($variables) { $output = '<' . $config['ow-el'] . $class . $attributes . '>' . $output . '' . $config['ow-el'] . '>'; } + // Free text prefix and suffixes (protected by filter_xss_admin() at save). + if (isset($config['prefix'])) { + $output = $config['prefix'] . $output; + } + if (isset($config['suffix'])) { + $output = $output . $config['suffix']; + } + return $output; } @@ -892,6 +900,11 @@ function ds_extras_ds_field_settings_alter(&$field_settings, $form, &$form_state } } } + + // Note that filter_xss_admin() doesn't close open tags which means that you can wrap an element in tags safely. + // Using NULL so that we can isset it later, which is quicker than !empty(). + $field_settings[$key]['formatter_settings']['ft']['prefix'] = !empty($values['prefix']) ? filter_xss_admin($values['prefix']) : NULL; + $field_settings[$key]['formatter_settings']['ft']['suffix'] = !empty($values['suffix']) ? filter_xss_admin($values['suffix']) : NULL; } } } diff --git a/modules/ds_extras/includes/ds_extras.admin.inc b/modules/ds_extras/includes/ds_extras.admin.inc index 5081e3d..8d7ad17 100644 --- a/modules/ds_extras/includes/ds_extras.admin.inc +++ b/modules/ds_extras/includes/ds_extras.admin.inc @@ -405,6 +405,19 @@ function ds_extras_field_template_settings_form(array &$form, array &$form_state } } + $form['ft']['prefix'] = array( + '#type' => 'textarea', + '#title' => 'Prefix', + '#default_value' => isset($field_settings['prefix']) ? $field_settings['prefix'] : FALSE, + '#prefix' => '