Quantcast
Channel: Editor — DataTables forums
Viewing all articles
Browse latest Browse all 3744

PreEdit issues - Joining two columns for insert/update

$
0
0

I'm using the following to insert the values of two columns into another column in the same table using the preEdit function.

It's producing the error:

Fatal error: Call to undefined method DataTables\Editor\Field::on() in /var/www/html/curriculum_mapper/programs/cm_mjd_plmed/program_data/unit_data.php on line 31

Line 31 is the line starting with the preEdit code...

Editor::inst( $db_cm_mjd_plmed, 'unit', 'unit_pk' )    
    ->field(
        Field::inst( 'unit.unit_code' ),
        Field::inst( 'unit.unit_name' ),
        Field::inst( 'unit.points' ),
        Field::inst( 'unit.modified' ),
        Field::inst( 'unit.modified_by' )->setValue( $user ),
        Field::inst( 'unit.year_fk' )
            ->options( Options::inst()
                ->table( 'year' )
                ->value( 'year_pk' )
                ->label( 'year_name' )
            )
    ->on('preEdit', function ($editor, $id, $values) {
  $editor->field('unit.unit_full_name')->setValue(
    $values['unit']['unit_code'] . $values['unit']['unit_name']
  );
})
            ->validator( 'Validate::dbValues' ),
        Field::inst( 'year.year_name' )
    )
    ->leftJoin( 'year', 'year.year_pk', '=', 'unit.year_fk' )
    ->join(
        Mjoin::inst( 'program_outcome' )
            ->link( 'unit.unit_pk', 'program_outcome_unit_lookup.unit_fk' )
            ->link( 'program_outcome.program_outcome_pk', 'program_outcome_unit_lookup.program_outcome_fk' )
           ->order( 'program_outcome.program_outcome asc' )
            ->fields(
                Field::inst( 'program_outcome_pk' )
                    ->options( Options::inst()
                        ->table( 'program_outcome' )
                       ->value( 'program_outcome_pk' )
        ->label( array('type', 'program_outcome') )
        ->render( function ( $row ) {
            return $row['type'] . ' - ' . $row['program_outcome'];
        } )
                        ->order( 'type' )
                    ),
                Field::inst( 'program_outcome' )
            )
    )
    ->process($_POST)
    ->json();

Viewing all articles
Browse latest Browse all 3744