Publisher does not support the Fluid field type. Please do not contact asking when support will be available.

If you purchased an add-on from expressionengine.com, be sure to visit boldminded.com/claim to add the license to your account here on boldminded.com.

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)

Mar 23, 2022

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

#2

BoldMinded (Brian)

Mar 23, 2022

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

#3

BoldMinded (Brian)

Mar 23, 2022

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)

Mar 23, 2022

Comment has been marked private.

#5

Full Circle Developers

Mar 24, 2022

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)

Mar 24, 2022

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

Mar 25, 2022

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:

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

        if (isset($data['rows'])) {
            foreach ($data['rows'] as $row) {
                // <a href="https://boldminded.com/support/ticket/2388">https://boldminded.com/support/ticket/2388</a>
                // 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])) {
                    $cleanData[$rowId][self::COL_HEADING_ROW] = $row[self::COL_HEADING_ROW];
                } else {
                    $cleanData[$rowId] = array_combine(range(1, count($row)), array_values($row));
                }

                $rowId++;
            }
        }

        return json_encode($cleanData);
    }
#8

BoldMinded (Brian)

Mar 25, 2022

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)

Mar 26, 2022

Comment has been marked private.

#10

Full Circle Developers

Mar 29, 2022

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

#11

BoldMinded (Brian)

Mar 29, 2022

Great to hear!

Login to reply