Hello all,
I'm trying to populate a select element in editor with contacts but I only want to see the contacts belonging to the company(dealer) I select and edit instead of all of them. So I have to select only the contacts with a particular dealernr, how can I get this value in the query? this is the code I have
Field::inst( 'bezoekverslagen.dealercontacts_id' )
->options( Options::inst()
->table( 'dealercontacts, bezoekverslagen' )
->value( 'dealercontacts.dealercontacts_id' )
->label( array('dealercontacts.initials', 'dealercontacts.firstname', 'dealercontacts.lastname') )
->where( function ($q) {
$q->where( 'xstop', 0 );
$q ->where('dealercontacts.dealernr', 'bezoekverslagen.dealernr');
})
)
->validator( 'Validate::dbValues' )
It's not working this way. The dealernr is in the row I select and want to edit, when editing I don't want to see all contacts, only thos that belong with that particular dealernr. How can I get this value? I hope someone can help, Thanks!!