Editor equivilent of writeCreate
Editor equivilent of writeCreate

Hi,
I have a bunch of fields that update on the writeCreate event. These fields are visible in dataTables but are not in the Editor form. For example, one select field is called Grades a grade has a $ value assigned so my script gets the value from the db then updates the row being edited in Editor.
This works perfectly for new rows but what event do I use for Edits?
a condensed version of the existing code below, Thanks.
TLDR: I need to create a new function like the one below to work with an edit event. Which event do I use? Thanks.
->on('writeCreate', function ($editor, $id, $values) {
$gradename_result = $editor
->db()
->query( 'select' )
->get( 'grade','status','farm','value' )
->table( 'grade' )
->where( 'id', $values['grade_id'] )
->exec()
->fetchAll();
$gradefarm = $gradename_result[0]['farm'];
$gradename = $gradename_result[0]['grade'];
$gradetype = $gradename_result[0]['status'];
$gradevalue = $gradename_result[0]['value'];
//update query
$editor->db()
->query('update', 'lease_units')
->set( 'lease_units.row_num', $the_number)
->set( 'lease_units.row_sec', $the_section)
->set('lease_units.lease', $leasename)
->set('lease_units.batch_id', $batchname)
->set('lease_units.unit_type', $unitname)
->set('lease_units.grade', $gradename)
->set('lease_units.extra6', $gradetype)
->set('lease_units.farm', $gradefarm)
->where('id', $id )
->exec();
}
This question has an accepted answers - jump to answer
Answers
You can use
writeEdit
, so pretty much the same - see manual page here.Colin
Thanks, Colin I used
writeEdit
. Works perfectly. Cheers.