Hello,
I am using the following:
Field::inst( 'bibliotheque_bibliotheques.oeuvre' )
->options( Options::inst()
->table( 'bibliotheque_oeuvres' )
->value( 'oeuvre_id' )
->label( array('oeuvre_id', 'titre', 'tome', 'auteur') )
->render( function ( $row ) {
if ( $row['tome'] & $row['auteur']) {
return $row['oeuvre_id'].' - '.$row['titre'].' ('.$row['tome'].') - ' .$row['auteur'] ;
}
if ( $row['tome']) {
return $row['oeuvre_id'].' - '.$row['titre'].' ('.$row['tome'].')' ;
}
return $row['oeuvre_id'].' - '.$row['titre'].' - ' .$row['auteur'].'' ;
}))
->validator( Validate::notEmpty( ValidateOptions::inst()
->message( 'Requis' ))),
To feed a select2 field:
{
label: "Oeuvre:",
name: "bibliotheque_bibliotheques.oeuvre",
type: "select2"
},
The problem is that:
* if oeuvre_id, titre and tome are all part of the mysql table bibliotheque_oeuvres
* I would rather like to use the field bibliotheque_auteurs.auteur (the name) instead of auteur (the id, foreign key)
Anyone would know how I can trick the above code to achieve that?