Where condition for editor select list populated from left join
Where condition for editor select list populated from left join

Trying to filter options in an editor select list.
The list is populated from table unit_group
though a left join.
I want to only add options from that table where unit_group.type == 'learning_event'.
I have tried with an AJAX error. Checked network -> XHR but there is no response.
Editor::inst( $db_cm_dopt, 'learning_event', 'learning_event_pk' )
->field(
Field::inst( 'learning_event.learning_event_name' ),
Field::inst( 'learning_event.type' ),
Field::inst( 'learning_event.modified' ),
Field::inst( 'learning_event.modified_by' )->setValue( $user),
Field::inst( 'learning_event.unit_group_fk' )
->options( Options::inst()
->table( 'unit_group' )
->value( 'unit_group_pk' )
->label( 'unit_group' )
>where( function ($q) {
$q->where( 'unit_group.type', 'learning_event%', 'LIKE' );
}
),
Field::inst( 'unit_group.unit_group' )
)
->leftJoin( 'unit_group', 'unit_group.unit_group_pk', '=', 'learning_event.unit_group_fk' )
This question has an accepted answers - jump to answer
This discussion has been closed.
Answers
There is also a fullext index on the type column, though I suspect that is not the issue. Also, I would prefer to have a == rather than LIKE.
That should be:
now works :-)
Glad you got it sorted!
Colin