select2 AJAX return format

select2 AJAX return format

klinglerklingler Posts: 90Questions: 42Answers: 2

Good morning

Have a select2 input field for a table which works fine for selecting several values and are stored as an INT array in Postgresql.

But...how has the JSON returned to look like so it shows correctly in the editor?

thank sin advance
richard

Answers

  • allanallan Posts: 63,482Questions: 1Answers: 10,467 Site admin

    An array of objects with label / value attributes is what the plugin is configured for by default (like the other "select" type fields in Editor). But you can use the optionsPair parameter for the field to modify that if you need.

    Allan

  • klinglerklingler Posts: 90Questions: 42Answers: 2

    Well...think sorted it out...the returned JSON has to look like:

    {
        "data": [
            {
                "DT_RowId": "155",
                "id": "155",
                "picture": "361",
                "name": "Some Name",
                "status": "7",
                "version": "0",
                "fremd": "f",
                "art": "3",
                "capability": [
                    28,
                    14
                ]
            },
    

    Not as label/value pair...

    Now have to figure out what is the fastest way to convert from pgsql array to PHP array (o;

Sign In or Register to comment.