label combine fields

label combine fields

nessinitsnessinits Posts: 86Questions: 27Answers: 0

I use the following text to generate a option list for a select:

        Field::inst( 'wl_contracts.approver' )
            ->options( Options::inst()
                ->table( 'persons' )
                ->value( 'persons_id' )
                ->label( 'lastname' )
            )->validator( 'Validate::dbValues' ),

The problem is that I would like to combine both the lastname and the firstname in the label. Is this possible?

This question has an accepted answers - jump to answer

Answers

  • allanallan Posts: 63,893Questions: 1Answers: 10,531 Site admin
    Answer ✓

    Yes, you can pass an array into the label method:

    ->label( ['firstname', 'last_name'] )
    

    You can also use a renderer to format the label output as you need if the standard space separator isn't good enough. Full details about it are available here.

    Allan

This discussion has been closed.