Editing tags - data from Mjoin

Editing tags - data from Mjoin

MarekAdamMarekAdam Posts: 30Questions: 9Answers: 1
edited September 2020 in Free community support

I want to implement tags (not html, press tags for topics). I adapted mysql tables from old system.

 ->join(
        Mjoin::inst( 'tagi_lista' )
            ->link( 'publikacje.id', 'tagi_id.pub_id' )
            ->link( 'tagi_lista.id', 'tagi_id.tag_id' )
            ->fields(
                Field::inst( 'id' )
                    ->options( 'tagi_lista', 'id', 'nazwa_pl' )
                    ->validator( 'Validate::notEmpty' ),
                Field::inst( 'nazwa_pl' )
            )
    )

Tags are visible in the table. The problem is that I have no idea how to add them in editor (editing by standard button).

  editor = new $.fn.dataTable.Editor( {
        ajax: "ajax.php",
        table: "#example",
        fields: [ {
            label: "ID:",
            name:  "pub.id"
        },
(...)

json data sending from php, section option

tagi_lista[].id:
0: {label: "tag1", value: 7}
1: {label: "tag2", value: 16}
2: {label: "tag3", value: 22}
3: {label: "tag4", value: 10}

Are there any simple solution for editing data from Mjoin (like uploaded files)?
Script have to show labels from table (label). I was thinking about jQuery UI AutoComplete, Select2 or similar but it too difficult for me without working examples with datatble.

If there is no simple solution for this i can pay for working with my table code.

This question has an accepted answers - jump to answer

Answers

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

    The most straightforward way of getting this to work in Editor is to use a checkbox or multi-select. From that you can select which tags you want to be marked.

    If you want to be able to type the labels, you would indeed need to use a library such as Select2. There is a plug-in available for it to work with Editor.

    Allan

  • MarekAdamMarekAdam Posts: 30Questions: 9Answers: 1

    allan, great example! Checkboxes are working. Its not good solution (i have more than 25 cols) but its working! Thanks for the idea!

    Edit:
    yesterday i was trying to use jQuery UI AutoComplete in my table but i have arrors and after few hours i give up. Today code select2 in few minutes. Its working! Datatables is amazing!

    The only problem is styling. The erasing X is on the label. Someone know how to repair this?
    https://www.dropbox.com/s/00cwz663543i9jj/Zrzut%20ekranu%202020-09-21%2023.25.58.png?dl=0

This discussion has been closed.