Save order button is missing

Created on 5 May 2018, almost 7 years ago
Updated 16 August 2023, over 1 year ago

I've had a client report that a draggable view which has previously worked reliably has lost its "save order" button.

I have reproduced the problem on dev, and it appear to be the module hook_form_alter() code that checks for empty results and removes the button. It expects a $form['draggableviews'][0] element to be present if there are results.

In my case this is not so - the view has results, but there is no element [0], results are keyed by nid and directly under the parent element, ie:

$form [
  'draggable_views' => [
    '#tree' => TRUE,
    [116] => [...],
    [419] => [...],
    [552] => [...],
  ],
];

Patching that line to check for empty element_children() fixes the problem for me, and should still catch the case where there is a single [0] element expected and that is missing:

  // If there is no results remove the save-order button.
  // if (!isset($form['draggableviews'][0])) {
  if (empty(element_children($form['draggableviews']))) {

Any thoughts on what might be going on here?

🐛 Bug report
Status

Needs review

Version

2.0

Component

Code

Created by

🇳🇿New Zealand john pitcairn

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • Open in Jenkins → Open on Drupal.org →
    Core: 7.x + Environment: PHP 5.3 & MySQL 5.5
    last update over 1 year ago
    Patch Failed to Apply
  • 🇳🇿New Zealand john pitcairn

    Revisiting - this is still an issue, but element_children() is now producing a php warning. The form element needs to be checked before calling that. This patch is against 2.1.0 for those of us still running 7.x in production.

    Dev is significantly different and will require a separate patch, if anyone cares any more.

Production build 0.71.5 2024