set a select label from more than one field

set a select label from more than one field

crush123crush123 Posts: 417Questions: 126Answers: 18

i have started using datatables with editor and am using the examples as a guide.

I have a select list on my editor form which is populated as follows....

if ( ! isset($_POST['action']) ) {
    // Get a list of patrons for the `select` list
$data['tblpatron'] = $db
    ->selectDistinct( 'tblpatron', 'PatronID as value, FirstName as label' )
    ->fetchAll();

I would like to concatenate FirstName and LastName Fields from my table as my label, is there a way to do this ?

This question has an accepted answers - jump to answer

Answers

  • crush123crush123 Posts: 417Questions: 126Answers: 18
    edited January 2015

    Actually, after a bit of playing, it was easier than I thought.

    change

    ->selectDistinct( 'tblpatron', 'PatronID as value, FirstName as label' )
    

    to

    ->selectDistinct( 'tblpatron', 'PatronID as value, concat(FirstName," ",LastName) as label' )
    
  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin
    Answer ✓

    Perfect - good to hear you found a solution :-).

    Allan

This discussion has been closed.