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 . ''; } + // 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' => '
', + ); + $form['ft']['suffix'] = array( + '#type' => 'textarea', + '#title' => 'Suffix', + '#default_value' => isset($field_settings['suffix']) ? $field_settings['suffix'] : FALSE, + '#suffix' => '
', + ); + // Another label needs some other stuff. unset($form['ft']['lb']['#description']); $form['ft']['lb']['#type'] = 'textfield'; diff --git a/modules/ds_extras/js/ds_extras.admin.js b/modules/ds_extras/js/ds_extras.admin.js index 7058213..ab533d6 100644 --- a/modules/ds_extras/js/ds_extras.admin.js +++ b/modules/ds_extras/js/ds_extras.admin.js @@ -77,7 +77,7 @@ Drupal.behaviors.settingsToggle = { // Remove margin from update button. $('.ft-update', field).css({'margin-top': '-10px'}); // Show wrappers. - $('.ow, .fis, .fi', field).show(); + $('.ow, .fis, .fi, .ft-wrappers', field).show(); } else { // Hide second, third, fourth, fifth and sixth label. @@ -85,7 +85,7 @@ Drupal.behaviors.settingsToggle = { // Add margin on update button. $('.ft-update', field).css({'margin-top': '10px'}); // Hide wrappers. - $('.ow, .fis, .fi', field).hide(); + $('.ow, .fis, .fi, .ft-wrappers', field).hide(); } // Colon.