MODX Community

Hide HTML tags inside Migx TV listbox values

I’m using a snippet to generate a dynamic Migx TV listbox in the Modx manager.

The snippet sends the following data per item:

foreach($data as $item){
    $listBox .= $item["name"] . " <data value='".$item["id"]."'></data>||";
return $listBox;
  1. Name: This should be visible so the user can choose the desired item.
  2. ID: This should be hidden

At this point the list loads fine in the Migx TV, only the name is displayed as intended.

The problem comes when you select you item, then this happens:

Is there a way to hide the HTML tags containing the ID’s? or; Is there another better way to pass the ID’s without showing them in the Migx UI?

Note: The method above works as intended with a multiple-listbox but since the user must select only one item a multiple-listbox is not suitable. Unless I can limit the selection to one.

Shouldn’t the options be in this format?

Option 1==value1||Option 2==value2

or in this case

$item["name"] . "==" . $item["id"] . "||";

Correct! Thank you @halftrainedharry that’s exactly what I was missing.