All add-ons currently require PHP 7.4 or greater.

On July 4th 2024 PHP 8.2 will be the new minimum requirement for all add-ons. Expect any add-on released after that date to require 8.2 or greater. Some releases may not immediately take advantage of 8.x specific features in PHP, which means you might, be able to continue using new releases in PHP 7.4, however, if you experience an error the first thing you should do is update to PHP 8.2 then create a support ticket if the error persists.

Please read about the changes to BoldMinded add-on licensing.

Ticket: Simple Table inside of Grid field, upon entry save, jumbles the saved columns and row data

Status Resolved
Add-on / Version Simple Grids & Tables 1.5.0
Severity
EE Version 6.2.7

Nick Bedard

Mar 23, 2022

1. Created a Grid field - ‘Test Grid with Simple Table’. The three fields within the grid are: Image (File), Simple Table. See Image 1 attached
2. Added ‘Test Grid with Simple Table’ to the ‘Test’ channel.
3. Create entry within the ‘Test’ channel containing data in the ‘Test Grid with Simple Table’ - see Image 2 attached
4. Save entry.
5. Page has refreshed with successful save message; all columns/rows data are rearranged from how data was entered.

#1

BoldMinded (Brian)

Thanks Nick. It’ll be a few days before I can look into this.

#2

BoldMinded (Brian)

What version of Bloqs? Are you up-to-date?

#3

BoldMinded (Brian)

If you re-save the entry with the correct values in the Simple Table field will it save and work correctly the 2nd time around?

#4

BoldMinded (Brian)

Comment has been marked private.

#5

Full Circle Developers

Sorry, never got any email notifications…

  1. Tried the new build; same issue occurs.
  2. “If you re-save the entry with the correct values in the Simple Table field will it save and work correctly the 2nd time around?” Unfortunately, no. Tested on latest version and same behavior.
  3. I do not have Bloqs installed on this site. This is a basic Grid field that the Simple Table is placed within.
#6

BoldMinded (Brian)

Hate to ask this, but are you 100% sure the files are up-to-date? I was able to replicate the issue, then I made a small code change, and the issue immediately resolved itself and I couldn’t replicate it again.

Specifically line 72 of ft.simple_table.php should have this:

ksort($row);

Do you see that in the file on your site?

#7

Full Circle Developers

Hi Brian,

Yes, I can confirm that line 72 loops as you mentioned. I re-uploaded the build you shared with me to ensure it, too… from ft.simple_table.php:

<pre><code> /** * @inheritdoc */ public function save($data) { $cleanData = []; $rowId = 1;

    if (isset($data['rows'])) &#123;
        foreach ($data['rows'] as $row) &#123;
            // https://boldminded.com/support/ticket/2388
            // Inside of a Grid field the columns get out of order(?)
            ksort($row);

            // Re-index starting at 1
            if (isset($row[self::COL_HEADING_ROW])) &#123;
                $cleanData[$rowId][self::COL_HEADING_ROW] = $row[self::COL_HEADING_ROW];
            &#125; else &#123;
                $cleanData[$rowId] = array_combine(range(1, count($row)), array_values($row));
            &#125;

            $rowId++;
        &#125;
    &#125;

    return json_encode($cleanData);
&#125;[/code]
#8

BoldMinded (Brian)

Can you create a video of this happening as you see it? I still can’t replicate it. Since adding that ksort() its saving fine for me every time.

#9

BoldMinded (Brian)

Comment has been marked private.

#10

Full Circle Developers

Sorry for the delay; it looks like that has resolved the issue!

#11

BoldMinded (Brian)

Great to hear!

Login to reply