Multi-Select field type (or other options) in Editor?

Multi-Select field type (or other options) in Editor?

gforstergforster Posts: 40Questions: 19Answers: 1

I have a very large amount of options (array) for a few various fields. Checkboxes work, but are cumbersome to scroll through. Select only allows a single selection. Are there any other options for a large array in an Editor field?

Something else that would be handy either in conjunction with the above or on its own would be the ability to populate via a search. e.g. start typing and display matching options, similar to the search function in DataTables.

Thanks!

Answers

  • kthorngrenkthorngren Posts: 20,144Questions: 26Answers: 4,736

    There are two that I know of here:
    https://editor.datatables.net/plug-ins/field-type/

    Selectize and Select2. I've used select2 and it works pretty good. I think with either you can type in the select input and filter the options shown.

    Kevin

  • allanallan Posts: 61,446Questions: 1Answers: 10,054 Site admin

    Another option is the built in select field type's multiple option. It uses a simple select element. Select2 and friends, as suggested by Kevin are an excellent step up from that, but they do also add a little more complexity.

    Allan

  • gforstergforster Posts: 40Questions: 19Answers: 1

    Having some issues using the multiple option (Namely it is sending:

    Invalid datetime format: 1366 Incorrect integer value: 'Array' for column 'srvrgrp_id' at row 1","data":[],"ipOpts":[],"cancelled":[],"debugSql"....
    

    So, whilst I troubleshoot that, I'm looking at Select2 and Chooser...really like the Pillbox feature of both of them which would solve a bunch of issues for me.

    However, I'm too dense to figure out how to implement and integrate either of these options. Is there a How-To-For-Dummies walkthrough available anywhere? thanks,

  • gforstergforster Posts: 40Questions: 19Answers: 1

    Good news: Got multi-select working properly with the normal select. Also, got Select2 implemented and mostly working! (look at that folks, you can teach an old dog!)

    Not-as-good news: Multi-select with Select2 is operating as a single-select (single selects work fine).

    example editor field:

    },{
       label: "Applications:",
       name: "APPS[].id",
       multiple: true,
       type: "select2",
       multiple: true
    },{
    

    Also, this is very minor...but on load of the editor modal window, the first Select2 dropdown displays already dropped-down.

  • kthorngrenkthorngren Posts: 20,144Questions: 26Answers: 4,736
    edited November 2017

    You have multiple twice in the config. Probably doesn't hurt anything though. But with Select2 you may need to use opts object for the multiple option. Here is an example of what I use:

            {
                "type": "select2",
                "label": "Page List:",
                "name": "main.fk_test_page_lists_list[]",
                "opts": {
                    "multiple": true,
                    "placeholder": "Select Device Types"
                }
            }
    

    the first Select2 dropdown displays already dropped-down.

    I haven't run into this. Maybe others have ideas.

    Kevin

This discussion has been closed.