Hi Bob, Hi Max,
I am trying to figure out how to explode an array in chronoconnectivity V5 such as to show only part of the array content whithin columns list.
e.g. : 'MyField' contains an array . As expected Model.MyField show all data in the array. ( data1,data2,data3,data4, .....)
Is there any way to explode the array to select some of them and put them back in a Model.MyField to display them.
I have tried using pre-display processing or PHP functions, but no success.
Any hint?
Best,
simelas
I am trying to figure out how to explode an array in chronoconnectivity V5 such as to show only part of the array content whithin columns list.
e.g. : 'MyField' contains an array . As expected Model.MyField show all data in the array. ( data1,data2,data3,data4, .....)
Is there any way to explode the array to select some of them and put them back in a Model.MyField to display them.
I have tried using pre-display processing or PHP functions, but no success.
Any hint?
Best,
simelas
Hi simelas,
Technically MyField doesn't contain an array, it contains a comma separated list. You should be able to explode this back into an array using the PHP functions box. The code there would be something like
Bob
Technically MyField doesn't contain an array, it contains a comma separated list. You should be able to explode this back into an array using the PHP functions box. The code there would be something like
Model.MyNewField: return explode(',', $cell);
That should give you the array - but I can't work out what you then want to do with the results?
Bob
Hi Bob,
thanks for the feed back.
( I missexpressed myself with the array. Yes indeed i was meaning explode a list into an array ...).
The goal is to explode the list in an array such as to use part of the content (of Myfield) and have it displayed in CCV5.
To build on your code: " Model.MyNewField: return explode(',', $cell); " and then display part of $cell content and / or use it for some other stuff.
I'll do some test and let you know about the outcome.
Cheers
Simelas
thanks for the feed back.
( I missexpressed myself with the array. Yes indeed i was meaning explode a list into an array ...).
The goal is to explode the list in an array such as to use part of the content (of Myfield) and have it displayed in CCV5.
To build on your code: " Model.MyNewField: return explode(',', $cell); " and then display part of $cell content and / or use it for some other stuff.
I'll do some test and let you know about the outcome.
Cheers
Simelas
Hi Bob,
me again,
Maybe i should have said that : i have a field which contains A,B,C,D . Goal is to retrieve one of this values and to show it in CCV5 .
Simelas
me again,
Maybe i should have said that : i have a field which contains A,B,C,D . Goal is to retrieve one of this values and to show it in CCV5 .
Simelas
Hi Bob,
In this particular case the data always hold the same position / index, and according to "input" or page to show , i need to retrieve one or other value according to their position in the list ( or in the array when list is exploded)..
With a custom code action in chronoforms as you know, it's pretty simple using for example $form->data['MyArray'][index] , but with CCV5 i have to admit i remain a little bit stuck about how to get the wished data back and show it in CCV5.
Simelas
In this particular case the data always hold the same position / index, and according to "input" or page to show , i need to retrieve one or other value according to their position in the list ( or in the array when list is exploded)..
With a custom code action in chronoforms as you know, it's pretty simple using for example $form->data['MyArray'][index] , but with CCV5 i have to admit i remain a little bit stuck about how to get the wished data back and show it in CCV5.
Simelas
Hi simelas,
If you want say the third element then the code would be something like
Bob
If you want say the third element then the code would be something like
Model.MyNewField: $temp = explode(',', $cell); return$temp[2];
remembering that the numbering will be 0, 1, 2, . . .
Bob
This topic is locked and no more replies can be posted.