![]() |
Admin 4/22/2022 |
Check this article. It explains how to convert JSON to PHP array, work with that array and then convert it back to JSON. |
D
|
david22585 author 5/31/2022 |
Just providing an update. Got this to work on the view page, but haven't tried the list page yet. Case: I have a form that submits work orders. Submission has 1 file upload field, and the users can upload pictures, videos, or documents. I wanted the documents/videos to be View As as "File" and the pictures to be View As "Image" with lightbox view. I created an alias field: workorders.files, On the events, View page, Process Record Value, I have the following: // Create PHP array Breaking it down is as follows: // Create PHP array This takes the JSON array and converts it into a PHP array to work with. // Images only This will search the array, and extract everything that is an image, removing all the other data that is not images. It then creates a new array, recreates the JSON, and leaves only images to be seen as a lightbox view on the page. // Everything but images The same as above, but leaves everything that is not an image, and removes all the images from the array. |
D
|
david22585 author 5/31/2022 |
This is how it looks on the view page. Also works on list pages as well. I have 1 field that stores all files, and you can see how images are in lightbox view while all other files are viewable as File type. |
D
|
david22585 author 6/17/2022 |
Just a quick update. Prior to PHP 8.1, this works on the list page. After going to 8.1,, the code fails on the list page, but works on the view page. It throw the following error on the list page with 8.1: Fatal error: Uncaught TypeError: array_filter(): Argument #1 ($array) must be of type array, int given in Not sure why this would work on the view page, and prior to 8.11111 on the list page, but not now. If anyone has any ideas, that would be great. |