Field options from left joined table
Field options from left joined table
edanyildiz
Posts: 43Questions: 13Answers: 4
Dear Allan,
I have multiple tables,
1) Customers
2) Companies
When i am adding a select field, is it possible to add other joined tables data?
Field::inst( 'offers.customer' )
->options( 'customers', 'id', array('firstname', 'lastname'), null, function ( $row ) {
return $row['firstname'].' '.$row['lastname'];} )
->validator( 'Validate::dbValues' ) ,
In above example, is it possible to return firstname + lastname + company (from other left joined table) ?
the join structure is like below;
$editor->leftJoin( 'customers', 'customers.id', '=', 'offers.customer' );
$editor->leftJoin( 'companies', 'companies.id', '=', 'customers.company' )
This question has an accepted answers - jump to answer
This discussion has been closed.
Answers
As in you want to show left joined information in the labels of the options?
That's not something that is currently possible wit the
Options
class in the PHP and .NET libraries I'm afraid. Having said that, it probably wouldn't be too difficult to add.ALlan
Yes, i like to show name+surname+ company name in options.
So, there is nothing to do for now.
thanky you.
I'm sorry to say not with the provided PHP and .NET libraries. They do provide the ability to get the data from the database yourself though. That would be the best way of doing this I think - have your own join based query to get the options.
Allan