Skip to content

Commit 703c462

Browse files
committed
Merge PR #673 from @zonky2
Fix tree picker: this prevents crosstalk with fields that have the same name in the mask as in the picker
2 parents 18d2e6c + acfe9f4 commit 703c462

5 files changed

Lines changed: 18 additions & 5 deletions

File tree

.phpcq.yaml.dist

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ phpcq:
5656
- 31C7E470E2138192
5757
- 5E6DDE998AB73B8E
5858
- A978220305CD5C32
59+
- 97B02DD8E5071466
5960
# Composer normalize
6061
- C00543248C87FB13
6162
# phpmd

src/Contao/View/Contao2BackendView/TreePicker.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -745,7 +745,9 @@ public function generate()
745745
->set('providerName', $this->sourceName)
746746
->set('readonly', $this->readonly);
747747

748-
$this->addOrderFieldToTemplate($template);
748+
if ('checkbox' === $this->fieldType) {
749+
$this->addOrderFieldToTemplate($template);
750+
}
749751

750752
return $template->parse();
751753
}

src/Contao/View/Contao2BackendView/Widget/FileTree.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -520,6 +520,8 @@ private function generateLink()
520520

521521
/**
522522
* {@inheritdoc}
523+
*
524+
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
523525
*/
524526
public function generate()
525527
{
@@ -539,6 +541,10 @@ public function generate()
539541
// Files can be null.
540542
if (null !== $files) {
541543
foreach ($files as $model) {
544+
if (null === $model || null === $model->uuid) {
545+
continue;
546+
}
547+
542548
$values[] = StringUtil::binToUuid($model->uuid);
543549
}
544550
}

src/Resources/contao/templates/widget_common_picker.html5

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,20 +4,24 @@ use Contao\System;
44
use Contao\StringUtil;
55

66
$requestToken = System::getContainer()->get('contao.csrf.token_manager')->getDefaultTokenValue();
7+
8+
$itemsTitle = '';
79
?>
810
<input type="hidden" name="<?= $this->name ?>" id="ctrl_<?= $this->id ?>" value="<?= \implode(',', \array_keys($this->values)) ?>">
911

1012
<?php $this->block('select-container'); ?>
1113
<div class="selector_container">
12-
<?php if ($this->hasOrder && \count($this->values)): ?>
14+
<?php if ($this->hasOrder && \count($this->values)):
15+
$itemsTitle = \sprintf(' title="%s"', $this->dragItemsHint);
16+
?>
1317
<p class="sort_hint">
1418
<?= $this->dragItemsHint ?>
1519
</p>
1620
<?php endif; ?>
1721

1822
<ul id="sort_<?= $this->id ?>"<?php if ($this->hasOrder): ?> class="sortable"<?php endif; ?>>
1923
<?php foreach ($this->values as $k=>$v): ?>
20-
<li data-id="<?= $k ?>"><?= $v ?></li>
24+
<li data-id="<?= $k ?>"<?= $itemsTitle ?>><?= $v ?></li>
2125
<?php endforeach; ?>
2226
</ul>
2327
</div>

src/Resources/contao/templates/widget_treepicker.html5

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22

33
<?php if ($this->hasOrder): ?>
44
<?php $this->block('multi-source-script'); ?>
5-
<input type="hidden" name="<?= $this->orderName ?>" id="ctrl_<?= $this->orderId ?>" value="<?= \implode(',', \array_keys($this->values)) ?>">
6-
<script>Backend.makeMultiSrcSortable("sort_<?= $this->id ?>", "ctrl_<?= $this->orderId ?>", "ctrl_<?= $this->id ?>")</script>
5+
<input type="hidden" name="<?= $this->orderName ?>" id="ctrl_order_<?= $this->orderId ?>" value="<?= \implode(',', \array_keys($this->values)) ?>">
6+
<script>Backend.makeMultiSrcSortable("sort_<?= $this->id ?>", "ctrl_order_<?= $this->orderId ?>", "ctrl_<?= $this->id ?>")</script>
77
<?php $this->endblock(); ?>
88
<?php endif; ?>
99

0 commit comments

Comments
 (0)