diff --git a/css/ds.admin.css b/css/ds.admin.css index e69de29..e80170e 100644 --- a/css/ds.admin.css +++ b/css/ds.admin.css @@ -0,0 +1,9 @@ + +.extra-field-settings { + display: none; + width: 300px; + z-index: 1000; + border: 1px solid #000; + padding: 5px; + background-color: #efefef; +} \ No newline at end of file diff --git a/ds.api.php b/ds.api.php index f85c229..5de14c2 100644 --- a/ds.api.php +++ b/ds.api.php @@ -339,6 +339,20 @@ function hook_ds_layout_info() { } /** + * Modify the field settings before they get saved. + * + * @param $field_settings + * A collection of field settings which keys are fields. + * @param $form + * The current form which is submitted. + * @param $form_state + * The form state with all its values. + */ +function hook_ds_field_settings_alter(&$field_settings, $form, $form_state) { + $field_settings['title']['region'] = 'left'; +} + +/** * Alter the region options in the field UI screen. * * This function is only called when a layout has been chosen. diff --git a/ds.field_ui.inc b/ds.field_ui.inc index f5786d1..60e4f7d 100644 --- a/ds.field_ui.inc +++ b/ds.field_ui.inc @@ -246,19 +246,8 @@ function ds_field_ui_layouts_save($form, &$form_state) { foreach ($fields as $key => $field) { - // Ignore the Field group module and the region to block plugin. - if ($key == '_add_new_group' || $key == '_add_new_block_region') { - continue; - } - - // If the field is in hidden region, do not save. Check if the - // field has a type key which means it's from Field API and - // we need to reset that type to 'hidden' so it doesn't get - // fired by Field API in the frontend. - if ($field['region'] == 'hidden') { - if (isset($field['type'])) { - $form_state['values']['fields'][$key]['type'] = 'hidden'; - } + // Make sure we need to save anything for this field + if (_ds_field_valid($key, $field, $form_state)) { continue; } @@ -304,7 +293,7 @@ function ds_field_ui_layouts_save($form, &$form_state) { } /** - * Save the field settings from the 'Manage display' screen. + * Save the Display Suite field settings from the 'Manage display' screen. */ function ds_field_ui_fields_save($form, &$form_state) { @@ -348,6 +337,9 @@ function ds_field_ui_fields_save($form, &$form_state) { $field_settings[$field] = $settings; } + // Let other modules modify the field settings before they get saved. + drupal_alter('ds_field_settings', $field_settings, $form, $form_state); + // Save the record. if (!empty($field_settings)) { $record = new stdClass; @@ -599,10 +591,12 @@ function _ds_field_ui_fields($entity_type, $bundle, $view_mode, &$form, &$form_s return; } - // Get the fields. + // Get the fields and put them on the form. $fields = ds_get_fields($entity_type, FALSE); $field_settings = ds_get_field_settings($entity_type, $bundle, $view_mode); + $form['#field_settings'] = $field_settings; + $table = &$form['fields']; $form['#ds_fields'] = array(); @@ -765,28 +759,52 @@ function _ds_field_ui_fields($entity_type, $bundle, $view_mode, &$form, &$form_s } /** + * Helper function to check if we need to save anything for this field. + */ +function _ds_field_valid($key, $field, &$form_state) { + $continue = FALSE; + + // Ignore the Field group module and the region to block plugin. + if ($key == '_add_new_group' || $key == '_add_new_block_region') { + $continue = TRUE; + } + + // If the field is in hidden region, do not save. Check if the + // field has a type key which means it's from Field API and + // we need to reset that type to 'hidden' so it doesn't get + // fired by Field API in the frontend. + if ($field['region'] == 'hidden') { + if (isset($field['type'])) { + $form_state['values']['fields'][$key]['type'] = 'hidden'; + } + $continue = TRUE; + } + + return $continue; +} + +/** * Return styles. */ -function _ds_styles() { - static $run = FALSE; +function _ds_styles($name = 'ds_styles_regions') { static $styles = array(); - if (!$run) { - $region_styles = trim(variable_get('ds_styles_regions', '')); - if (!empty($region_styles)) { - $styles[''] = t('None'); - $region_styles = explode("\n", $region_styles); - foreach ($region_styles as $key => $value) { + if (!isset($styles[$name])) { + $styles[$name] = array(); + $custom_styles = trim(variable_get($name, '')); + if (!empty($custom_styles)) { + $styles[$name][''] = t('None'); + $custom_styles = explode("\n", $custom_styles); + foreach ($custom_styles as $key => $value) { $classes = explode("|", $value); $key = trim($classes[0]); - $name = isset($classes[1]) ? trim($classes[1]) : $key; - $styles[$key] = $name; + $friendly_name = isset($classes[1]) ? trim($classes[1]) : $key; + $styles[$name][$key] = $friendly_name; } } - $run = TRUE; } - return $styles; + return $styles[$name]; } diff --git a/ds.module b/ds.module index ef94802..432e58d 100644 --- a/ds.module +++ b/ds.module @@ -402,6 +402,11 @@ function ds_field_attach_view_alter(&$build, $context) { foreach ($field_values as $key => $field) { + // Ignore if this field is not a DS field. + if (!isset($fields[$key])) { + continue; + } + $field = $fields[$key]; $field['formatter'] = $field_values[$key]['format']; @@ -420,6 +425,7 @@ function ds_field_attach_view_alter(&$build, $context) { '#field_name' => $key, '#bundle' => $bundle, '#entity_type' => $entity_type, + '#view_mode' => $view_mode, '#access' => TRUE, '#items' => array( 0 => array( diff --git a/ds.registry.inc b/ds.registry.inc index e1d3b2d..e473a90 100644 --- a/ds.registry.inc +++ b/ds.registry.inc @@ -21,10 +21,10 @@ function _ds_menu() { 'file path' => drupal_get_path('module', 'system'), ); - // Custom styles. + // Styles. $items['admin/structure/ds/styles'] = array( 'title' => 'Styles', - 'description' => 'Define classes which you can use as classes for regions.', + 'description' => 'Define styles which you can use as classes on regions and fields (if available).', 'page callback' => 'drupal_get_form', 'page arguments' => array('ds_styles_form'), 'file' => 'ds.styles.inc', diff --git a/js/ds.js b/js/ds.js index 0db51ca..8f1af01 100644 --- a/js/ds.js +++ b/js/ds.js @@ -1,6 +1,38 @@ (function($) { +Drupal.DisplaySuite = Drupal.DisplaySuite || {}; +Drupal.DisplaySuite.fieldopened = ''; + +/** + * Field settings. + */ +Drupal.behaviors.settingsToggle = { + attach: function (context) { + // remove click from link + $('.fs-link').click(function(e) { + e.preventDefault(); + }); + + // Add click event to field settings link. + $('.fs-link').click(function(){ + var settings = $(this).siblings('.extra-field-settings'); + if (Drupal.DisplaySuite.fieldopened != '' && Drupal.DisplaySuite.fieldopened != settings.attr('id')) { + $('#' + Drupal.DisplaySuite.fieldopened).hide(); + } + + if (settings.is(':visible')) { + settings.hide(); + } + else { + settings.slideDown('normal'); + } + // Store the opened setting. + Drupal.DisplaySuite.fieldopened = settings.attr('id'); + }); + } +}; + /** * Row handlers for the 'Manage display' screen. */ diff --git a/modules/ds_extras/ds_extras.install b/modules/ds_extras/ds_extras.install index 95b723d..b683e94 100644 --- a/modules/ds_extras/ds_extras.install +++ b/modules/ds_extras/ds_extras.install @@ -75,6 +75,8 @@ function ds_extras_uninstall() { variable_del('ds_extras_region_blocks'); variable_del('ds_extras_switch_view_mode'); variable_del('ds_extras_vd'); + variable_del('ds_extras_field_settings'); + variable_del('ds_extras_field_styles'); db_drop_field('node_revision', 'ds_switch'); } diff --git a/modules/ds_extras/ds_extras.module b/modules/ds_extras/ds_extras.module index 581a3be..6a37e46 100644 --- a/modules/ds_extras/ds_extras.module +++ b/modules/ds_extras/ds_extras.module @@ -40,6 +40,15 @@ function ds_extras_module_implements_alter(&$implementations, $hook) { // Because it's possible to turn on/off features for DS extras, // we'll unset hooks here if necessary which otherwhise do nothing at all. + // Disable the field settings feature. + $fs_hooks = array( + 'form_ds_styles_form_alter', + 'ds_field_settings_alter' + ); + if (!variable_get('ds_extras_field_settings', FALSE) && in_array($hook, $fs_hooks)) { + unset($implementations['ds_extras']); + } + // Disable the region to block feature. $region_hooks = array( 'ds_layout_region_alter', @@ -66,12 +75,16 @@ function ds_extras_module_implements_alter(&$implementations, $hook) { 'field_extra_fields', 'entity_info', 'ds_fields_info', - 'theme_registry_alter', 'ctools_plugin_api', ); if (!variable_get('ds_extras_vd', FALSE) && in_array($hook, $vd_hooks)) { unset($implementations['ds_extras']); } + + // Theme registry alter is used by 2 features. + if ((!variable_get('ds_extras_vd', FALSE) && !variable_get('ds_extras_field_settings', FALSE)) && $hook == 'theme_registry_alter') { + unset($implementations['ds_extras']); + } } /** @@ -79,9 +92,21 @@ function ds_extras_module_implements_alter(&$implementations, $hook) { */ function ds_extras_settings($form) { + $form['fs'] = array( + '#type' => 'fieldset', + '#title' => t('Field settings'), + ); + + $form['fs']['ds_extras_field_settings'] = array( + '#type' => 'checkbox', + '#title' => t('Enable'), + '#description' => t('Toggle this checkbox to enable the "Field settings" functionality. With this feature, you can change properties per field: classes, label and wrappers.'), + '#default_value' => variable_get('ds_extras_field_settings', FALSE), + ); + $form['switch'] = array( '#type' => 'fieldset', - '#title' => t('Switch view modes'), + '#title' => t('Node switch view modes'), ); $form['switch']['ds_extras_switch_view_mode'] = array( @@ -131,10 +156,178 @@ function ds_extras_settings_submit($form, &$form_state) { // Clear module_implements cache and rebuild menu. cache_clear_all('entity_info:', 'cache', TRUE); cache_clear_all('module_implements', 'cache_bootstrap'); + cache_clear_all('theme_registry:', 'cache', TRUE); menu_rebuild(); } /** + * Implements hook_form_FORM_ID_alter(). + */ +function ds_extras_form_ds_styles_form_alter(&$form, &$form_state) { + $form['ds_styles_fields'] = array( + '#type' => 'textarea', + '#title' => t('Styles for fields'), + '#default_value' => variable_get('ds_styles_fields', ''), + '#description' => t('Configure styles which you can add to fields on the "manage display" screens. Add multiple styles line per line.
If you want to have a friendly name, separate class and friendly name by |, but this is not required. eg:
class_name_1
class_name_2|Friendly name
class_name_3
') + ); +} + +/** + * Implements hook_ds_field_settings_alter(). + */ +function ds_extras_ds_field_settings_alter(&$field_settings, $form, $form_state) { + + $fields = $form_state['values']['fields']; + foreach ($fields as $key => $field) { + + // Make sure we need to save anything for this field. + if (_ds_field_valid($key, $field, $form_state)) { + continue; + } + + // Get the values. + $values = $fields[$key]['format']['extra-fs']; + + // Another label. + if (!empty($values['field_label']) && $fields[$key]['label'] != 'hidden') { + $field_settings[$key]['field_label'] = $values['field_label']; + } + + // Remove all wrappers. + if ($values['remove_all_wrappers']) { + $field_settings[$key]['remove_all_wrappers'] = TRUE; + continue; + } + + // Remove outer wrapper. + if ($values['remove_outer_wrapper']) { + $field_settings[$key]['remove_outer_wrapper'] = TRUE; + } + else { + // Remove default classes on outher div. + if ($values['classes_remove']) { + $field_settings[$key]['classes_remove'] = TRUE; + } + + // Extra outer div classes, do not save empty field classes. + $classes = implode(' ', $values['field_classes']); + if (!empty($classes)) { + $field_settings[$key]['field_classes'] = $classes; + } + } + + // Remove field-items wrapper + if (!empty($values['remove_field_items_wrapper'])) { + $field_settings[$key]['remove_field_items_wrapper'] = TRUE; + } + + // Remove field wrapper + if (!empty($values['remove_field_wrapper'])) { + $field_settings[$key]['remove_field_wrapper'] = TRUE; + } + // Another wrapper. + elseif (!empty($values['field_wrapper'])) { + $field_settings[$key]['field_wrapper'] = $values['field_wrapper']; + } + } +} + +/** + * Overriden function of theme_field(). + */ +function theme_ds_field($variables) { + + static $field_settings = array(); + if (!isset($field_settings[$variables['element']['#entity_type']][$variables['element']['#bundle']][$variables['element']['#view_mode']])) { + $field_settings[$variables['element']['#entity_type']][$variables['element']['#bundle']][$variables['element']['#view_mode']] = ds_get_field_settings($variables['element']['#entity_type'], $variables['element']['#bundle'], $variables['element']['#view_mode']); + } + + // Alter the theming of this field if it's found in the field settings. + $field_name = $variables['element']['#field_name']; + if (isset($field_settings[$variables['element']['#entity_type']][$variables['element']['#bundle']][$variables['element']['#view_mode']][$field_name])) { + $output = ''; + + // Get the configuration for this field. + $config = $field_settings[$variables['element']['#entity_type']][$variables['element']['#bundle']][$variables['element']['#view_mode']][$field_name]; + + // Render the label, if it's not hidden. + if (!$variables['label_hidden']) { + $label = $variables['label']; + // Alter the label if configured. + if (isset($config['field_label'])) { + $label = t(check_plain($config['field_label'])); + } + $label = '
' . $label . ': 
'; + } + + // Remove all wrappers and just display the field(s). + if (isset($config['remove_all_wrappers'])) { + $output = ''; + foreach ($variables['items'] as $delta => $item) { + if (!$variables['label_hidden']) { + $output .= $label; + } + $output .= drupal_render($item); + } + return $output; + } + + // Label. + if (!$variables['label_hidden']) { + $output .= $label; + } + + // Render the items. + if (!isset($config['remove_field_items_wrapper'])) { + $output .= '
'; + } + $wrapper = 'div'; + if (isset($config['field_wrapper'])) { + $wrapper = $config['field_wrapper']; + } + foreach ($variables['items'] as $delta => $item) { + if (!isset($config['remove_field_wrapper'])) { + $classes = 'field-item ' . ($delta % 2 ? 'odd' : 'even'); + $output .= '<' . $wrapper . ' class="' . $classes . '"' . $variables['item_attributes'][$delta] . '>'; + } + $output .= drupal_render($item); + if (!isset($config['remove_field_wrapper'])) { + $output .= ''; + } + } + if (!isset($config['remove_field_items_wrapper'])) { + $output .= '
'; + } + + // Classes on the top-level DIV. + $space = ' '; + $top_level_classes = $variables['classes']; + if (isset($config['classes_remove'])) { + $space = ''; + $top_level_classes = ''; + } + if (isset($config['field_classes'])) { + $top_level_classes .= $space . strtr($config['field_classes'], '_', '-'); + } + if (!empty($top_level_classes)) { + $top_level_classes = ' class="' . $top_level_classes . '"'; + } + + // Render the top-level DIV. + if (!isset($config['remove_outer_wrapper'])) { + $output = '' . $output . ''; + } + + return $output; + } + + // Default theming of the field through theme_field(). We call this directly + // and not with theme('hook'), because otherwhise we'll end up in an endless loop. + return theme_field($variables); +} + + +/** * Implements hook_permission(). */ function ds_extras_permission() { @@ -221,7 +414,7 @@ function ds_extras_form_node_form_alter(&$form, $form_state, $form_id) { '#title' => t('View mode'), '#options' => $options, '#default_value' => isset($node->ds_switch) ? $node->ds_switch : '', - '#description' => t('Switch to a different view mode to display the default full page view of this node.'), + '#description' => t('Switch to a different view mode to display the full page view of this node.'), '#weight' => -1, ); } @@ -233,6 +426,129 @@ function ds_extras_form_node_form_alter(&$form, $form_state, $form_id) { */ function ds_extras_form_field_ui_display_overview_form_alter(&$form, &$form_state) { + // Field settings. + if (variable_get('ds_extras_field_settings', FALSE) && isset($form['#ds_layout'])) { + + $field_settings = $form['#field_settings']; + $field_styles = _ds_styles('ds_styles_fields'); + + $i = 1; + foreach (element_children($form['fields']) as $key) { + + $form['fields'][$key]['format']['extra-fs'] = array( + '#prefix' => '' . t('Field settings') . '
', + '#suffix' => '
', + ); + $i++; + + // Remove all wrappers. + $form['fields'][$key]['format']['extra-fs']['remove_all_wrappers'] = array( + '#type' => 'checkbox', + '#title' => t('Remove all wrappers'), + '#default_value' => isset($field_settings[$key]['remove_all_wrappers']) ? TRUE : FALSE, + ); + + // Remove outer wrapper. + $form['fields'][$key]['format']['extra-fs']['remove_outer_wrapper'] = array( + '#type' => 'checkbox', + '#title' => t('Remove outer wrapper'), + '#default_value' => isset($field_settings[$key]['remove_outer_wrapper']) ? TRUE : FALSE, + '#states' => array( + 'visible' => array( + 'input[name="fields[' . $key . '][format][extra-fs][remove_all_wrappers]"]' => array('checked' => FALSE), + ), + ), + ); + + // Remove default outer div classes. + $form['fields'][$key]['format']['extra-fs']['classes_remove'] = array( + '#type' => 'checkbox', + '#title' => t('Remove default outer DIV classes'), + '#default_value' => isset($field_settings[$key]['classes_remove']) ? TRUE : FALSE, + '#states' => array( + 'visible' => array( + 'input[name="fields[' . $key . '][format][extra-fs][remove_all_wrappers]"]' => array('checked' => FALSE), + 'input[name="fields[' . $key . '][format][extra-fs][remove_outer_wrapper]"]' => array('checked' => FALSE), + ), + ), + ); + + // Field styles. + if (!empty($field_styles)) { + $field_styles_select = array( + '#type' => 'select', + '#multiple' => TRUE, + '#options' => $field_styles, + '#title' => t('Extra outer DIV classes'), + '#default_value' => isset($field_settings[$key]['field_classes']) ? explode(' ', $field_settings[$key]['field_classes']) : array(), + '#states' => array( + 'visible' => array( + 'input[name="fields[' . $key . '][format][extra-fs][remove_all_wrappers]"]' => array('checked' => FALSE), + 'input[name="fields[' . $key . '][format][extra-fs][remove_outer_wrapper]"]' => array('checked' => FALSE), + ), + ), + ); + $form['fields'][$key]['format']['extra-fs']['field_classes'] = $field_styles_select; + } + else { + $form['fields'][$key]['format']['extra-fs']['field_classes'] = array( + '#type' => 'value', + '#value' => array(''), + ); + } + + // Remove outer wrapper. + $form['fields'][$key]['format']['extra-fs']['remove_field_items_wrapper'] = array( + '#type' => 'checkbox', + '#title' => t('Remove "field-items" wrapper'), + '#default_value' => isset($field_settings[$key]['remove_field_items_wrapper']) ? TRUE : FALSE, + '#states' => array( + 'visible' => array( + 'input[name="fields[' . $key . '][format][extra-fs][remove_all_wrappers]"]' => array('checked' => FALSE), + ), + ), + ); + + $form['fields'][$key]['format']['extra-fs']['remove_field_wrapper'] = array( + '#type' => 'checkbox', + '#title' => t('Remove field wrapper'), + '#default_value' => isset($field_settings[$key]['remove_field_wrapper']) ? TRUE : FALSE, + '#states' => array( + 'visible' => array( + 'input[name="fields[' . $key . '][format][extra-fs][remove_all_wrappers]"]' => array('checked' => FALSE), + ), + ), + ); + + // Another wrapper + $form['fields'][$key]['format']['extra-fs']['field_wrapper'] = array( + '#type' => 'textfield', + '#size' => 10, + '#title' => t('Different field wrapper'), + '#default_value' => isset($field_settings[$key]['field_wrapper']) ? $field_settings[$key]['field_wrapper'] : '', + '#states' => array( + 'visible' => array( + 'input[name="fields[' . $key . '][format][extra-fs][remove_all_wrappers]"]' => array('checked' => FALSE), + 'input[name="fields[' . $key . '][format][extra-fs][remove_field_wrapper]"]' => array('checked' => FALSE), + ), + ), + ); + + // Another label + $form['fields'][$key]['format']['extra-fs']['field_label'] = array( + '#type' => 'textfield', + '#title' => t('Label'), + '#size' => 10, + '#default_value' => isset($field_settings[$key]['field_label']) ? $field_settings[$key]['field_label'] : '', + '#states' => array( + 'invisible' => array( + 'select[name="fields[' . $key . '][label]"]' => array('value' => 'hidden'), + ), + ), + ); + } + } + // Views displays. if (variable_get('ds_extras_vd', FALSE)) { // Add an additional submit callback. @@ -496,6 +812,9 @@ function ds_extras_theme_registry_alter(&$theme_registry) { if (variable_get('ds_extras_vd', FALSE)) { $theme_registry['views_view']['preprocess functions'][] = 'ds_extras_preprocess_view'; } + if (variable_get('ds_extras_field_settings', FALSE)) { + $theme_registry['field']['function'] = 'theme_ds_field'; + } } /** diff --git a/tests/ds.entities.test b/tests/ds.entities.test index a2f950a..f17ca80 100644 --- a/tests/ds.entities.test +++ b/tests/ds.entities.test @@ -16,13 +16,15 @@ class dsNodeTests extends dsBaseTest { public static function getInfo() { return array( 'name' => t('Node display'), - 'description' => t('Tests for display of nodes.'), + 'description' => t('Tests for display of nodes and fields.'), 'group' => t('Display suite'), ); } - function testDSNodeEntity() { - + /** + * Helper function to setup for all kinds of tests. + */ + function entitiesTestSetup() { // Create a node. $settings = array('type' => 'article'); $node = $this->drupalCreateNode($settings); @@ -54,6 +56,7 @@ class dsNodeTests extends dsBaseTest { 'fields[php_field][region]' => 'left', 'fields[body][region]' => 'right', 'fields[links][region]' => 'footer', + 'fields[body][label]' => 'above', ); $this->dsConfigureUI($fields); @@ -87,6 +90,16 @@ class dsNodeTests extends dsBaseTest { ); $this->dsConfigureUI($fields, 'admin/structure/types/manage/article/display/teaser'); + return $node; + } + + /** + * Test basic node display fields. + */ + function testDSNodeEntity() { + + $node = $this->entitiesTestSetup(); + // Switch view mode on full node page. $edit = array('ds_switch' => 'teaser'); $this->drupalPost('node/' . $node->nid . '/edit', $edit, t('Save')); @@ -136,4 +149,89 @@ class dsNodeTests extends dsBaseTest { $this->assertNoRaw('

Recent content

'); $this->assertNoRaw('Recent content'); } + + /** + * Tests on field settings. + */ + function testDSFieldSettings() { + $node = $this->entitiesTestSetup(); + + // Create field styles. + $edit = array('ds_styles_fields' => "test_field_class\ntest_field_class_2|Field class 2"); + $this->drupalPost('admin/structure/ds/styles', $edit, t('Save configuration')); + + // Standard theming of field. + $this->drupalGet('node/' . $node->nid); + $body_field = $node->body[$node->language][0]['value']; + $this->assertRaw("
Body: 

" . $body_field . "

+
"); + + // With extra class. + $edit = array( + 'fields[body][format][extra-fs][field_classes][]' => 'test_field_class' + ); + $this->dsConfigureUI($edit); + $this->drupalGet('node/' . $node->nid); + $this->assertRaw("
Body: 

" . $body_field . "

+
"); + + // With 2 extra classes. + $edit = array( + 'fields[body][format][extra-fs][field_classes][]' => array('test_field_class', 'test_field_class_2'), + ); + $this->dsConfigureUI($edit); + $this->drupalGet('node/' . $node->nid); + $this->assertRaw("
Body: 

" . $body_field . "

+
"); + + // With another label. + $edit = array( + 'fields[body][format][extra-fs][field_classes][]' => array(), + 'fields[body][format][extra-fs][field_label]' => 'My body', + ); + $this->dsConfigureUI($edit); + $this->drupalGet('node/' . $node->nid); + $this->assertRaw("
My body: 

" . $body_field . "

+
"); + + // With another wrapper. + $edit = array( + 'fields[body][format][extra-fs][field_label]' => '', + 'fields[body][format][extra-fs][field_wrapper]' => 'span', + ); + $this->dsConfigureUI($edit); + $this->drupalGet('node/' . $node->nid); + $this->assertRaw("
Body: 

" . $body_field . "

+
"); + + // With extra class but all other classes removed. + $edit = array( + 'fields[body][format][extra-fs][classes_remove]' => '1', + 'fields[body][format][extra-fs][field_classes][]' => 'test_field_class', + 'fields[body][format][extra-fs][field_wrapper]' => '', + ); + $this->dsConfigureUI($edit); + $this->drupalGet('node/' . $node->nid); + $this->assertRaw("
Body: 

" . $body_field . "

+
"); + + // With outer div removed. + $edit = array( + 'fields[body][format][extra-fs][remove_outer_wrapper]' => '1', + 'fields[body][format][extra-fs][field_wrapper]' => '', + ); + $this->dsConfigureUI($edit); + $this->drupalGet('node/' . $node->nid); + $this->assertRaw("
Body: 

" . $body_field . "

+
"); + + // With all wrappers removed. + $edit = array( + 'fields[body][format][extra-fs][remove_all_wrappers]' => '1', + ); + $this->dsConfigureUI($edit); + $this->drupalGet('node/' . $node->nid); + $this->assertRaw("
+
Body: 

" . $body_field . "

"); + } } diff --git a/tests/ds_test.module b/tests/ds_test.module index 02fcc7c..1916227 100644 --- a/tests/ds_test.module +++ b/tests/ds_test.module @@ -11,6 +11,7 @@ function ds_test_install() { variable_set('ds_extras_region_to_block', TRUE); variable_set('ds_extras_switch_view_mode', TRUE); + variable_set('ds_extras_field_settings', TRUE); } /**