Retrieve data from a field with multiple select

Retrieve data from a field with multiple select

GargiucnGargiucn Posts: 71Questions: 20Answers: 0

I'm trying to use multiple select dropdown to store multiple choices in a single field but I'm in trouble and I hope you can help me...


TABLE `bandi`
  `ban_id` int(10),
  `ban_sogid` varchar(20)
Related TABLE `soggetti`
  `sog_id` tinyint(3)
  `sog_descr` varchar(30)


    Field::inst( 'bandi.ban_sogid' )
        ->options( Options::inst()
            ->table( 'soggetti' )
            ->value( 'sog_id' )
            ->label( 'sog_descr' ) 
            ->order( 'sog_descr ASC' )
        ->validator( Validate::dbValues() )          


        label: "Soggetti:",
        name: "bandi.ban_sogid",
        type: "select",
        multiple: true,
        separator: ',',

Field bandi.ban_sogid after multiple selection: "1,2,3 "

In table view the name corresponding to the first value within the field bandi.ban_sogid appears correctly,
but I did not understand how and where to insert the code to visualize other values.


This question has an accepted answers - jump to answer


  • allanallan Posts: 56,444Questions: 1Answers: 8,957 Site admin
    Answer ✓

    Hi Giuseppe,

    Can you show me your DataTable code that you are using to display the information? If you have 1,2,3 as the value, you will need to split that string on the comma and then look up the label for each one (assuming you don't also save the label in the same row in the db, which would be fairly pointless!).


This discussion has been closed.