Warning: Illegal string offset 'edit' in [...]

All ApPHP DataGrid script bugs discussion. Questions and requests here.
Please, use a $debug_mode = true; before you say "Why Nothing Works ?!" (solves 90% of all issues)

Moderators: ne_moj, zewa, vadimako, ne_moj, zewa, vadimako

mposse
Junior
Junior
Posts: 20
Joined: Nov 2nd, '10, 03:45

Warning: Illegal string offset 'edit' in [...]

Postby mposse » Sep 30th, '16, 02:10

Hello
I had to upgrade my datagrid just a couple of days ago when I moved to a newer php version.
I am in the latest version now.
I have been going through the code that no longer works and figuring out changes that need to be made to be compatible with the new dg version, but I have run into a problem that I can't figure out.
I am getting this message in one of the pages that uses the grid

Warning: Illegal string offset 'edit' in [...]/datagrid/datagrid.class.php on line 4805

The line 4805 seems to be related to multiple grids in the same page, which is actually the case of this page I am working on, but all the commands seem to be correct.
Enabling debug mode doesn't show anything special

administrator
Site Admin
Site Admin
Posts: 5990
Joined: Jan 7th, '09, 23:18
Contact:

Re: Warning: Illegal string offset 'edit' in [...]

Postby administrator » Sep 30th, '16, 13:18

What version you work with?
Post here this line of code, so we could check it.

mposse
Junior
Junior
Posts: 20
Joined: Nov 2nd, '10, 03:45

Re: Warning: Illegal string offset 'edit' in [...]

Postby mposse » Sep 30th, '16, 16:34

I managed to remove the error by commenting the $anotherDatagrid section, obviously I have wrong code there.
I am on the latest version ApPHP DataGrid Pro (AJAX enabled) version 8.1.8, but the code was working on version 6, so I am trying to figure out the differences.
It seems that $anotherDatagrid now is defined as a multidimensional array.
The problem that remains is the action buttons are not being generated.
The code is

Code: Select all

if (isset($_GET['fcr_mode']) && $_GET['fcr_mode'] == "add") {
      if ($debug_mode) echo "I was here";
      $fcr_add_edit_template['body'] .= "[CREATE]   ";
   }
   if (isset($_GET['fcr_mode']) && $_GET['fcr_mode'] == "details") {
      $fcr_add_edit_template['body'] .= "[EDIT]   [BACK]   ";
   }
   if (isset($_GET['fcr_mode']) && $_GET['fcr_mode'] == "update") {
      $fcr_add_edit_template['body'] .= "[EDIT]   [BACK]   ";
   }
   if (isset($_GET['fcr_mode']) && $_GET['fcr_mode'] == "edit") {
      $fcr_add_edit_template['body'] .= "[UPDATE]   ";
   }


I get the "I was here" message, but [CREATE] doesn't renders the action button.
Weird because on another page, defined the same way, it works fine. I am searching for any difference but I can't find anything.
Debugging doesn't show any error message.

Martin

mposse
Junior
Junior
Posts: 20
Joined: Nov 2nd, '10, 03:45

Re: Warning: Illegal string offset 'edit' in [...]

Postby mposse » Sep 30th, '16, 19:29

New update
I tested
$fcr_add_edit_template['body'] .= "[ADD][CREATE][EDIT][DELETE][BACK][CANCEL][UPDATE][MULTIROW_CHECKBOX][ROWS_NUMERATION]";
an the only button that renders is [CANCEL], all others just display on the screen as text, with the exception of [CREATE] that doesn't display at all
Attachments
action items.png
action items.png (4.8 KiB) Viewed 1606 times

mposse
Junior
Junior
Posts: 20
Joined: Nov 2nd, '10, 03:45

Re: Warning: Illegal string offset 'edit' in [...]

Postby mposse » Sep 30th, '16, 19:55

New updated
Same exact code, if using [ADD], it displays [ADD] on the screen, if using [CANCEL] it renders a cancel button that works, if using [CREATE] doesn't display anything. It does look to me like a bug.

Code: Select all

$fcr_add_edit_template['body'] .= "[ADD]   ";
$fcr_add_edit_template['body'] .= "[CANCEL]   ";
$fcr_add_edit_template['body'] .= "[CREATE]   ";

mposse
Junior
Junior
Posts: 20
Joined: Nov 2nd, '10, 03:45

Re: Warning: Illegal string offset 'edit' in [...]

Postby mposse » Oct 1st, '16, 23:23

Found the problem and fixed it, for the benefit of others. It had to do with the modes definition.

This combination showed the CREATE button.

Code: Select all

$modes = array(
      "add"=>array("view"=>true, "edit"=>false, "type"=>"image", "show_add_button"=>"outside"),
      "edit"=>array("view"=>false, "edit"=>true, "type"=>"button"),
      "cancel"=>array("view"=>false, "edit"=>false, "type"=>"button"),
      "details"=>array("view"=>false, "edit"=>false, "type"=>"image"),
      "delete"=>array("view"=>false, "edit"=>false, "type"=>"image")
   );
   $grid->setModes($modes);


Return to “ApPHP DataGrid {bugs}”