Populate select from unrelated table
Populate select from unrelated table
peterbrowne
Posts: 314Questions: 54Answers: 0
in Editor
I want to populate a select from a DB table and column unit.unit_name
that is unrelated to other data on the editor form and associated data. I'm not sure how to do that.
I have tried the following but expectedly get
DataTables warning: table id=learning_event_outcome_table - An SQL error occurred: SQLSTATE[42S22]: Column not found: 1054 Unknown column 'unit' in 'field list'
Editor::inst( $db_cm_mjd_plmed, 'learning_event_outcome', 'learning_event_outcome_pk' )
->field(
Field::inst( 'learning_event_outcome.learning_event_outcome' ),
Field::inst( 'learning_event_outcome.modified' ),
Field::inst( 'learning_event_outcome.modified_by' )->setValue( $user ),
Field::inst( 'unit' )
->options(Options::inst()
->table('unit')
->value('unit_name')
->label('unit')
->order('unit_name asc')
->render( function ($row) {
return $row['unit_name'];
} )
)
)
This question has an accepted answers - jump to answer
Answers
OK, got it working with:
and the get_units.php script...
Nice one - thanks for posting back with your solution.
Allan