Need help passing array of number into in custom block

Permalink
Hi, guy
in my edit.php i manage to pass array of integer into my controller problem its how im suppose to save it then pass it to the view i know i have the array because i pass the count($array) into view and show exact number of item i have. Any help will be appreciated.

 
JohntheFish replied on at Permalink Reply
JohntheFish
In the controller save() method you need to serialize it. Then in the view() method or the view itself, unserialize() it.

You can do this with php serialize/unserialize, or via json, or just implode/explode for simple data.

I have just put together some more detailed notes as a howto. The link below will work in a day or two when the howto is approved:

http://www.concrete5.org/?cID=569848...
DarkVision12 replied on at Permalink Reply
The link doesn't work for me I serialize and unserialize work with a array of string but when trying with array of number it's showing a error 1064
JohntheFish replied on at Permalink Reply
JohntheFish
It may be something within the serialized string that throws mysql, perhaps nested quotes or use of single quotes.

Some ideas to try (not all at the same time):

- map each array element to a string first
- run addslashes() on the serialized string
- use JSON instead of php serialize
JohntheFish replied on at Permalink Reply
JohntheFish
The howto on saving and serializing arrays is now published:

http://www.concrete5.org/documentation/how-tos/developers/save-and-...