Select2 ad Editor

Select2 ad Editor

GargiucnGargiucn Posts: 104Questions: 29Answers: 0

It would be possible for Editor users to have a complete example to use select2 instead of select especially in edit?.
Using select2 instead of edit without modifying php works perfectly but in the edit mode does not preserve the value of the field...

Field::inst( 'clienti.cli_naz' )
    ->options( Options::inst()
        ->table( 'nazioni' )
        ->value( 'naz_cod' )
        ->label( ['naz_nome','naz_cod'] )
        ->render( function ( $row ) {
            return $row['naz_nome'].' ('.$row['naz_cod'].')';
        } )             
        ->order( 'naz_nome ASC' )
    )   
{
    label: "Nazione",
    name: "clienti.cli_naz",
    type: "select2",
    opts: {
        // placeholder: "",
        allowClear: false,
        initialValue: true,
    },
    // type: "select",
    // def: "IT",
    // placeholderDisabled: true
},          

Thank you,
Giuseppe

This question has an accepted answers - jump to answer

Answers

  • allanallan Posts: 61,665Questions: 1Answers: 10,096 Site admin
    Answer ✓

    Hi Giuseppe,

    We plan to add a number of Select2 examples once we've finished our current round of work - so perhaps in a month or two.

    Regarding the issue you are having - could you use the debugger to give me a trace please - click the Upload button and then let me know what the debug code is.

    Thanks,
    Allan

  • GargiucnGargiucn Posts: 104Questions: 29Answers: 0

    No errors, I just don't know how to keep the field value in edit...

    Thanks,
    Giuseppe

  • allanallan Posts: 61,665Questions: 1Answers: 10,096 Site admin

    Most of the time, the problem with this sort of thing is that the value selected is not in the options list, or it is the label that is being given as the value.

    If you could use the debugger to give me a trace, that might help me pin point what is going wrong.

    Allan

This discussion has been closed.