MIGXdb CMP and managing csv values with input type file/image

I inherited a simple DB to be now managed with MIGXdb.

  • One row equals one item.
  • Each item has a field that contains multiple image paths, comma separated. (eg: path/to/img1,jpg,path/to/img2.jpg,path/to/img3.jpg)

So far so good. Now I need to somehow “explode” these CSVs into multiple image input types in migxdb’s CMP, so that the csv items can be managed using file- or image-selector input types. (similiar to listbox-multiple)

MIGX has never let me down so far but I can’t seem to figure out how to make this happen.
Anyhow there must be a better way than exploding the field content into multiple fields (image1, image2, image3) only to be able to make it backend manageable.

Any ideas? Am I missing something obvious?

PS: I could change the commas to “||” if that helps.

the best way would be, if that values would be stored as json. Then you could just use a MIGX - field to manage the images within that one field.

hey - thanks for the quick answer.
I guess converting the values to JSON wouldn’t be a problem but you lost me at “just use a MIGX Field”.

You mean using “Input TV type” = migx?
I think I get the general idea but I’m not sure how to get there. Do you have an example?

Yes. In the MIGX configuration for you database table use “Input TV type” = migx for the column with the images and set “Configs” to the name of another MIGX-configuration.

In this second configuration create a field with “Input TV type” = image and a “Fieldname” like (for example) img_path.

Then make sure that the JSON-values in the DB-column have a structure like this:

[{"MIGX_id":"1","img_path":"path/to/img1.jpg"},{"MIGX_id":"2","img_path":"path/to/img2.jpg"}]

Yay - thanks a lot. That was just what I needed and I’m almost there.

using a JSON array’d example in the DB and and a new MIGX tv productImages I now see and (almost) edit the images in a MIGXdb widget. I suspected but wasn’t aware you could go this far in MIGXdb. :slight_smile:

So I entered productImages into Input TV and “migx” into Input TV type and I’m one step further.
It seems to pick up the grid column(s) from productImages but not the form tabs.
When I right click and edit a row it just presents me one default textfield titled “Title”. Saving (the text) works fine though.

The formtabs field in productImages should be ok:

[
{"caption":"Images", "fields":[
    {"field":"img_path","caption":"Image","inputTV":"images"}
]}
]

or do I have to define them elsewhere for this purpose?

let Input TV empty. Only use input TV type and do all your configuration for formtabs and columns in a MIGX configuration (within the MIGX CMP).
You don’t need a actual MIGX TV for that.

took me while to figure out what you meant by “…in a MIGX configuration” but it’s working now.

for anyone as slow as me:

  • create a new MIGX configuration like you would for a MIGXdb config
  • create your form tabs & grid columns there
  • use the name of this new config in Configs

easy. once you’ve figured it out.

Thanks a lot for your help!