⚠ In case you've missed it, we have migrated to our new website, with a brand new forum. For more details about the migration you can read our blog post for website migration. This is an archived forum. ⚠

  •     

profile picture

when I click the view button



siarik

siarik
  • profile picture
  • Member

Posted 13 August 2013 - 04:04 AM

I have used grocery crud 1.4

 

when I click the view button theme flexigrid

I found an error

 

A PHP Error was encountered

Severity: Notice

Message: Array to string conversion

Filename: libraries/Grocery_CRUD.php

Line Number: 2346

I use Xampp 1.8.1

but in Xampp 1.7.7 not found error

 

anyone can help ?

 


Amit Shah

Amit Shah
  • profile picture
  • Member

Posted 13 August 2013 - 08:09 AM

Well such notices you can just turn off by switching the ci mode in the apps root folder (index.php) file from development mode to production mode.


Kobus

Kobus
  • profile picture
  • Member

Posted 14 August 2013 - 13:30 PM

Amit,

 

While the messages can be switched off in CI, it does not in fact indicate that there is not a problem with GC. That warning means something is wrong in the code somewhere, and it could have issues in the crud, so I believe this post is not yet answered.

 

Any other ideas on what can cause this? I am getting the same error.

 

Line 2344 - 2348 are as follows:

 

protected function get_readonly_input($field_info,$value)
{
    return '<div id="field-'.$field_info->name.'" class="readonly_label">'.$value.'</div>';
}

 

The problem is related to relation-n-n tables in the content. I have, for example, blocks, and you can have many blocks on a page, but a specific block can be used on many pages, so it is an m:n relationship.

 

Changing the code to this:

 

protected function get_readonly_input($field_info,$value)
{
    if (isset($value) && !is_array($value))
    {
        return '<div id="field-'.$field_info->name.'" class="readonly_label">'.$value.'</div>';
    }
    reset($value);
    $key = key($value);
    if (isset($value[$key]))
    {
        return '<div id="field-'.$field_info->name.'" class="readonly_label">'.$value[$key].'</div>';
    }
    return;
}

 

Solves the problem effectively, although most likely not optimally. I will submit the patch via Github shortly.

 

Regards,

 

Kobus

 


Kobus

Kobus
  • profile picture
  • Member

Posted 14 August 2013 - 14:30 PM

I have submitted the proposed change on Github. Do with it as you wish :-) I also submitted some documentation rewording (fixing grammar mistakes) and an updated Afrikaans language file.


Sherif Sakr

Sherif Sakr
  • profile picture
  • Member

Posted 26 August 2013 - 01:33 AM

after  reading  kobus post

 

  I think  the solution will be  small edit in  Filename: libraries/Grocery_CRUD.php Line 2344 - 2348 are as follows:

 

 

protected function get_readonly_input($field_info,$value)
    {
        //return '<div id="field-'.$field_info->name.'" class="readonly_label">'.$value.'</div>';

         if (isset($value) && !is_array($value))
    {
        return '<div id="field-'.$field_info->name.'" class="readonly_label">'.$value.'</div>';  // this will  end function and return  value
    }
  
     // or implode the array 
        return  '<div id="field-'.$field_info->name.'" class="readonly_label">'.implode (' ,  ' , $value).'</div>';
   
   
    }
 


web-johnny

web-johnny
  • profile picture
  • Administrator
  • 1,166 posts

Posted 26 August 2013 - 15:36 PM

Hello guys,

 

This problem is now solved at the latest code of grocery CRUD. Please check https://github.com/scoumbourdis/grocery-crud and download the latest code in order to see it working. As for the changes that has been done, check:  https://github.com/scoumbourdis/grocery-crud/issues/231

 

Cheers


Kobus

Kobus
  • profile picture
  • Member

Posted 27 August 2013 - 09:10 AM

Hi Sherif,

 

I have thought about using your solution as well, and tested it before submitting mine, however, this resulted in an unruly, unreadable list of items which does not make sense to show in read mode. I have therefore opted to show only the first item.

 

There are certainly merits in both approaches though - and I personally don't really mind which one is implemented.

 

Kind regards,

 

Kobus


web-johnny

web-johnny
  • profile picture
  • Administrator
  • 1,166 posts

Posted 27 August 2013 - 19:30 PM

Hello [member='Kobus'] and thank you for your great contribution,

 

Your contribution was actually an inspiration for me to fix the bug. You are right that this is a bit ugly. Maybe at the future I will implement a more link. So for example we will show only the first three results and then the user needs to press the link more in order to see the rest results.

 

Please also guys consider that the read functionality was a last minute contribution from Luis Fernando Gomes , so It had some issues that I haven't notice. So I am sorry for that.

 

Cheers

Johnny


PatrySeema

PatrySeema
  • profile picture
  • Member

Posted 04 September 2013 - 07:10 AM

I have thought about using your solution as well.