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.

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: Toggle field within Simple Grid don’t output “0” if toggle is off and kinda keep in memory the previous setting after toggle change.

Status Resolved
Add-on / Version Simple Grids & Tables 1.0.2
Severity
EE Version 5.3.0

pixi

Feb 25, 2020

I’m back :D

So I made a grid field with a Simple Grid within and toggles as columns.

I have 4 toggle coumns followed by 2 text column. I display the row in the template by writing this :

{my_simple_grid:quota_rate}
<li>
{toggle_quota_a} {toggle_quota_b} {toggle_quota_c} {toggle_quota_d} {rate} {increase}
</li>
{/my_simple_grid:quota_rate}

On the 1st row I switch on toggle A, I put a number in rate column and in increase column.
On the 2nd row I switch on toggle B, I put a number in rate column and in increase column.
On the 3d row I switch on toggle C, I put a number in rate column and in increase column.
On the 4th row I switch on toggle D, I put a number in rate column and in increase column.

So it should output :
1 0 0 0 my_number my_increase
0 1 0 0 my_number my_increase
0 0 1 0 my_number my_increase
0 0 0 1 my_number my_increase

but it outputs this :

1 my_number my_increase
1 my_number my_increase
1 my_number my_increase
1 my_number my_increase

So if I understand well, first problem is it outputs only the ones that are toggle on. Moreover, then I change : on the 1st row I switch off toggle A and switch on toggle B, and it outputs this :
1 0 my_number my_increase
1 my_number my_increase
1 my_number my_increase
1 my_number my_increase

It behaves like this with every change. It’s like it keeps in memory/cache the previous value of the toggle. And much more, it outputs well “0” when the toggle is off (behaviour I would like to have from the beginning) but not for every off. When you start to change multiple times it becomes messier.

I tested this bug on the new installation where I tested the previous Simple grid bug, so brand new, no other addons installed.
Let me know if you want the credentials to see it in action with real datas.

#1

BoldMinded (Brian)

Can you provide some screenshots illustrating the issue too?

#2

pixi

Comment has been marked private.

#3

BoldMinded (Brian)

I just did a test to replicate this, and it appears to be working as expected. Your template logic is a little difficult to follow, are you sure it is correct? This is what I setup:

Screenshot of the field: https://d.pr/i/yssiOi

Template used:

{grid}
    {grid:total_rows}
    <table>
        {grid:simple_grid}
        <tr switch="{switch='odd|even'}" data-total-rows="{total_rows}">
            <th>{if alpha}alpha{/if}</th>
            <td>{if beta}beta{/if}</td>
            <td>{if charlie}charlie{/if}</td>
        </tr>
        {/grid:simple_grid}
    </table>
{/grid}

Screenshot of output: https://d.pr/i/FO4eqS

html of output:

<table>
        
        <tbody><tr switch="odd" data-total-rows="3">
            <th>alpha</th>
            <td></td>
            <td></td>
        </tr>
        
        <tr switch="even" data-total-rows="3">
            <th></th>
            <td>beta</td>
            <td></td>
        </tr>
        
        <tr switch="odd" data-total-rows="3">
            <th></th>
            <td></td>
            <td>charlie</td>
        </tr>
        
    </tbody></table>
#4

BoldMinded (Brian)

It’s not supposed to output an actual 0. If its not checked, then it’s assumed it is false, as my test above indicates that it is working.

#5

BoldMinded (Brian)

I did a little more testing and did notice the issue. Try the build in the next comment.

#6

BoldMinded (Brian)

Comment has been marked private.

#7

pixi

It seems like this build fixes the momery/cache after toggle change issue, thank you very much Brian.

For output of “0” : it is not a bug but a bias if I understand you well. But may I suggest you to make the toggle output a “0” in case of false to correspond to the native toggle templating behaviour? It is said in the EE docs :

"When used as a single variable, e.g. {toggle_field}, it will output a 1 for the “on” position and 0 for the “off” position. Handy if you are exporting channel data for later import or external use. Or writing templates for robot overlords. Or for switching between two images:
/images/robot_{toggle_field}.png <!-- robot_0.png or robot_1.png -->"

Reading this, we we tend to expect it to work like this too in SG&T. Don’t you think?

For my present project I can use the {if toggle} but I think of other one’s projects or future projects of mine that may need this. It would be so nice to have it.

#8

BoldMinded (Brian)

Thanks for pointing that out. I can make that change.

#9

BoldMinded (Brian)

Comment has been marked private.

#10

pixi

At your service 😉

OOh thank you very much! And that goes fast!

#11

pixi

OOhh noooo ;( , now that is fixed I wanted to upgrade it on the real project install and when I upgraded with the last build I have this error when trying to edit entry :

Fatal error: Uncaught Error: Call to undefined method Basee\App::isInstallingOrUninstallingAddon() in /var/www/vhosts/my_domain/user/addons/simple_grids/abstract.simple_grids.php:276 Stack trace: #0 /var/www/vhosts/my_domain/user/addons/simple_grids/abstract.simple_grids.php(61): SimpleGrids->validateLicense() #1 /var/www/vhostsmy_domain/user/addons/simple_grids/ft.simple_grid.php(63): SimpleGrids->__construct('simpleGrid') #2 /var/www/vhosts/my_domain/ee/legacy/libraries/api/Api_channel_fields.php(380): Simple_grid_ft->__construct() #3 /var/www/vhosts/my_domain/ee/legacy/libraries/api/Api_channel_fields.php(331): Api_channel_fields->_instantiate_handler('simple_grid') #4 /var/www/vhosts/my_domain/ee/legacy/libraries/Gri in /var/www/vhosts/my_domain/user/addons/simple_grids/abstract.simple_grids.php on line 276

and the page is styleless

Whyyyy?

#12

pixi

How can I uninstall it entirely to re-install it completely?

#13

BoldMinded (Brian)

What other boldminded add-ons do you have installed? You may need to get new builds of them too (I might have to send you new ones b/c they haven’t been posted publicly)

#14

pixi

Comment has been marked private.

#15

BoldMinded (Brian)

Comment has been marked private.

#16

pixi

ah cool it works! thanks. I think we’re done here then … for now :D :D

Login to reply