Select dropdowns

Select dropdowns

kringelkringel Posts: 16Questions: 9Answers: 0

Hello.

Is there a way to add options in select dropdown e.g. via input?
For example, you have an input field, u pass a value and submit it. Then it appears in select options.

One more question. I tried to add a blank option as placeholdervalue, so that the default value is always empty. But it doesn't work quite correctly. Example below

By default its empty. Thats good. I select an option and create a row. Everything is fine.

Then I open "Add" menu one more time and its not empty. Value is already set.

I try to add a row without changing anything and an error pops up. Reselecting the same option fixes the error. How can i solve this?

My goal is to make smth similar to this

Thanks in advance!!

This question has accepted answers - jump to:

Answers

  • colincolin Posts: 15,237Questions: 1Answers: 2,599
    Answer ✓

    If this using Editor? You could look at Select2, that has options like that,

    Colin

  • kringelkringel Posts: 16Questions: 9Answers: 0
    edited December 2020

    Thanks for the direction where to look. I was able to find what I needed. Can you please tell me how to implement select tagging (https://select2.org/tagging) in the table editor?

    <select class="form-control">
      <option selected="selected">orange</option>
      <option>white</option>
      <option>purple</option>
    </select>
    
    $(".js-example-tags").select2({
      tags: true
    });
    

    My code

            fields: [
                {
                    "label": "\u0412\u0438\u0434 \u0434\u0435\u044f\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438:",
                    "name": "activity",
                    "type": "select",
                    placeholderValue: "",
                    "options": [
                        "",
                        "option1",
                        "option2",
                        "option3",
                        "option4"
                    ]
                },
    

    Thanks in advance!

  • allanallan Posts: 63,214Questions: 1Answers: 10,415 Site admin
    Answer ✓

    With the Select2 plug-in for Editor you can pass in configuration options for Select2 using the opts parameter for the field - so in this case:

    {
      type: 'select2',
      opts: {
        tags: true
      },
      name: 'activity',
      ...
    }
    

    Allan

This discussion has been closed.