Hi there, I'm trying to use the value of a migx tv with multiple textfields as input options for another tv, a checkbox tv with a list of categories. The idea behind this is that I want a site admin to easily manage the input options for this tv without accessing the tv itself.
I did this as follows (probably not the best way, I'm not a programmer):
1) created the admin-input tv named categoryInputOptions:
input type: migx
Form type:
[{
"caption":"Categories",
"fields": [{
"field":"category",
"caption":"Category"
}]
}]
Grid columns:
[
{"header": "Category", "width": "30", "sortable": "false", "dataIndex": "category"}
]
2) Created the category tv named category:
input type: checkbox
input option values:
@EVAL return $modx->runSnippet('readCategoryOptions');
3) Created the snippet to display the category options from the first TV named readCategoryOptions:
<?php
$resource = $modx->getObject('modResource',1);
$migxEntries = $resource->getTVValue('categoryInputOptions');
$migxEntries2 = json_decode($migxEntries);
This is where I get stuck. The TV categoryInputOptions is managed on the resource with id 1. So I first get that resource and then I get the value of the TV categoryInputOptions on that resource. I understand this is a JSON string, so I try to decode it. This gives me an array.
My question is: how do I turn that array ($migxEntries2) into a string that can be used by TV category? I think it should be a string in the form value1||value2||value3.
I tried everything I could find on arrays, like implode, but nothing seems to work. Probably something small.. Anyone got a hint for me?