joined table multiple index question

joined table multiple index question

edanyildizedanyildiz Posts: 43Questions: 13Answers: 4

Dear Allan,

Sorry for simple questions since i am a newbie.
I have a joined table (users table) and trying to record the updater and creator in to projects table.

I can manage to get the id's of the creator and the updater.
But i can't manage to get names in the editor.
I tried to use
Field::inst( 'users.user_firstname' )
but i don't know the value coming from server is the name of the projects_creator or projects_updater

    Field::inst( 'projects.creator' )
    ->options( 'users', 'user_id', array('user_firstname', 'user_lastname'), null, function ( $row ) {
    return $row['user_firstname'].' '.$row['user_lastname'];} ) 
    ->validator( 'Validate::dbValues' ) ,

    Field::inst( 'projects.updater' )
        ->set( false )
                    ->set( Field::SET_BOTH )
        ->setValue( $_POST['userid'] ),

This question has an accepted answers - jump to answer

Answers

  • edanyildizedanyildiz Posts: 43Questions: 13Answers: 4
    Answer ✓

    Sorry, i have managed to solve the problem using alias.

    Field::inst( 'creator.user_firstname' ),
    Field::inst( 'updater.user_firstname' ),

    $editor->leftJoin( 'users as creator', 'creator.user_id', '=', 'projects.creator' );
    $editor->leftJoin( 'users as updater', 'updater.user_id', '=', 'projects.updater' );

This discussion has been closed.