postEdit returns empty $row
postEdit returns empty $row
for PHP library
Editor->on( 'postCreate', function ( $editor, $id, $values, $row )
$row works just fine. However,
Editor->on( 'postEdit', function ( $editor, $id, $values, $row )
$row is always empty while $values has only the edited values. What I need is some other values in the same row that set to be read only.
thanks.
This question has an accepted answers - jump to answer
This discussion has been closed.
Answers
this was tricky.
it turned out the reason is that I'm using both
preEdit
andpostEdit
where
preEdit
contains$editor->field( )->setValue( );
to set a value based on some logic.Still, the problem not solved yet. how can I use preEdit to set some value then work on postEdit row data?
So if you use
preEdit
with thefield()->setValue()
the$row
is completely empty inpostEdit
!? That absolutely should not be happening!Could you show me your code please?
Thanks,
Allan
Hi Allan,
my apologies.. you're right. my analysis wasn't correct
it's all about the where condition. Once
stage
has been changed inpreEdit
,postEdit
is useless in my case.->where( 'stage', 1, '=' )
->on( 'preEdit', function ( $editor, $id, $values){ $editor->field('stage')->setValue(2);})
->on( 'postEdit', function ( $editor, $id, $values, $row ){...})
My alternative solution now is removing
preEdit
and do updatestage
inpostEdit
usingdb()->update()
methodThank you Allan
Ah!
There is also the
writeEdit
event which can be used likepostEdit
, but it is triggered before the libraries read data from the database, so you can modify the table's data before it is read.Allan
cannot use that;
$row
is not available forwriteEdit
using
db()->update()
was sufficient for me.Thank you