setting a php session variable in the php processing script
setting a php session variable in the php processing script
I want to do something that seems like it should be simple but I can not figure it out. I want to take a FEILD:: instance and pass it to a php session variable.
I tried:
Editor::inst( $db, 'ia_application.plf_data', 'plf_id' )
->field(
Field::inst( 'ia_application.plf_data.plf_id' ),
->on( 'preCreate', function ( $editor, $values ) {
$editor
->field( 'ia_application.plf_data.plf_id' )
->setValue( $_SESSION['plf_id'] );
} )
->on( 'preEdit', function ( $editor, $id, $values ) {
$editor
->field( 'ia_application.plf_data.plf_id' )
->setValue( $_SESSION['plf_id'] );
} )
->process($_POST)
->json();
with no joy... Can someone please show me how I can accomplish this?
Thanks in advance!
This discussion has been closed.
Answers
You mean you want to pass it a PHP session variable (not “to a variable”)?
What you have above looks correct to me. When creating or editing a row, that field should be set to the value in your session variable.
If you add
->debug(true)
just before the->process($_POST)
and then copy / paste the return from the server when you perform and edit or create action (from the browser’s network panel) can you show me those returns please?Allan