Hi,

I created a custom layout according to the explanation at http://drupal.org/node/1098068
The problem is that when I drag and drop any field into a region it always ends up in the first region (after ajax save) which in my case is the region "header". When I use the selects instead of the drag & drop, the fields move to the correct region.

I can't use the selects though because my fields need to be added to fieldsets within these regions (and you know you can only select to which region you want to assign a field and not the fieldsets within regions)

Here's the code for my custom template (altough I don't think that has anything to do with it):

3col_3row_equal_width.inc.inc

<?php
function ds_3col_3row_equal_width() {
  return array(
    'label' => t('Three column three row - Equal width'),
    'regions' => array(
      'header' => t('Header'),
      'first_left' => t('Left (first)'),
      'first_middle' => t('Middle (first)'),
      'first_right' => t('Right (first)'),
      'second_left' => t('Left (second)'),
      'second_middle' => t('Middle (second)'),
      'second_right' => t('Right (second)'),  
      'third_left' => t('Left (third)'),
      'third_middle' => t('Middle (third)'),
      'third_right' => t('Right (third)'),
      'footer' => t('Footer')       
    ),
    // Add this line if there is a default css file.
    'css' => TRUE,
  );
}
?>

3col_3row_equal_width.tpl.php

<div class="<?php print $classes;?> clearfix">

  <?php if (isset($title_suffix['contextual_links'])): ?>
    <?php print render($title_suffix['contextual_links']); ?>
  <?php endif; ?>
  
  <div class="ds-row-first ds-row">
    <?php if ($header): ?>
      <div class="ds-header<?php print $header_classes; ?>">
        <?php print $header; ?>
      </div>
    <?php endif; ?>  

    <?php if ($first_left): ?>
      <div class="ds-first-left<?php print $first_left_classes; ?>">
        <?php print $first_left; ?>
      </div>
    <?php endif; ?> 
    
    <?php if ($first_middle): ?>
      <div class="ds-first-middle<?php print $first_middle_classes; ?>">
        <?php print $first_middle; ?>
      </div>
    <?php endif; ?> 
    
    <?php if ($first_right): ?>
      <div class="ds-first-right<?php print $first_right_classes; ?>">
        <?php print $first_right; ?>
      </div>
    <?php endif; ?>           
  </div>
  
  <div class="ds-row-second ds-row">
    <?php if ($second_left): ?>
      <div class="ds-second-left<?php print $second_left_classes; ?>">
        <?php print $second_left; ?>
      </div>
    <?php endif; ?> 
    
    <?php if ($second_middle): ?>
      <div class="ds-second-middle<?php print $second_middle_classes; ?>">
        <?php print $second_middle; ?>
      </div>
    <?php endif; ?> 
    
    <?php if ($second_right): ?>
      <div class="ds-second-right<?php print $second_right_classes; ?>">
        <?php print $second_right; ?>
      </div>
    <?php endif; ?>           
  </div>  
  
  <div class="ds-row-third ds-row">
    <?php if ($third_left): ?>
      <div class="ds-third-left<?php print $third_left_classes; ?>">
        <?php print $third_left; ?>
      </div>
    <?php endif; ?> 
    
    <?php if ($third_middle): ?>
      <div class="ds-third-middle<?php print $third_middle_classes; ?>">
        <?php print $third_middle; ?>
      </div>
    <?php endif; ?> 
    
    <?php if ($first_right): ?>
      <div class="ds-third-right<?php print $third_right_classes; ?>">
        <?php print $third_right; ?>
      </div>
    <?php endif; ?>  
    
    <?php if ($footer): ?>
      <div class="ds-footer<?php print $footer_classes; ?>">
        <?php print $footer; ?>
      </div>
    <?php endif; ?>             
  </div>
  
</div>

Comments

Percept’s picture

Btw the reason I can't just use the selects is because my fields need to be assigned to fieldsets within the regions and that's only possible with the drag & drop option.

swentel’s picture

Yeah, it shouldn't be related to the custom layout, this will probably also happen on other layouts too. It's a clash between Field UI, DS and Fieldgroup - I'll have to do some extensive testing here.

Percept’s picture

The strange thing is, when I drag and drop a field in my "first_left" region under the fieldset, the field jumps to the first region (header) like described above. But when I save this, the front end actually gets the correct output ie field inside fieldset in the correct region. When I reload the "manage display" page, the field is still showing up in the header region though. Hope that helps anything to narrow down the problem.

Thanks for the quick reply btw.

swentel’s picture

Looks like the drag and drop doesn't like a region with an underscore, this was fun to find out. Hope I can fix this with the javascript.

swentel’s picture

Status: Active » Needs review

Here's a patch. The patch also fixes a notice which is in dev, if you don't want to upgrade right now, just open ds.js and add following line in the regionChange: function

  regionChange: function (region) {

    // Replace dashes with underscores.
    region = region.replace('-', '_');
swentel’s picture

StatusFileSize
new783 bytes
Percept’s picture

Great, thanks a lot!

swentel’s picture

Status: Needs review » Fixed

Ok committed :)

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

dshields’s picture

Version: 7.x-1.0 » 7.x-2.x-dev
Component: User interface » Code
Status: Closed (fixed) » Needs review
StatusFileSize
new666 bytes

While this patch has been fixed in the core Display Suite JavaScript code, it is still an issue in ds_forms submodule. Only the first instance is being replaced. This patch resolves that.

aspilicious’s picture

Status: Needs review » Fixed

THNX!

  • aspilicious committed 9b6ea12 on 7.x-2.x authored by dshields
    Issue #1175414 by swentel, dshields: Issue with drag and dropping fields...

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.