on edit how to update a field with value of a session var?

Questionson edit how to update a field with value of a session var?
Michael Olson asked 2 years ago

When I update a value in the grid on edit I need to  update a field with the value of a users session variable.

 

I know this doesn’t work but maybe it gives you an idea of what I am trying to do:

//PROCESSED_BY
$col = array();
$col[“title”] = “Processor”; // caption of column, can use HTML tags too
$col[“name”] = “processed_by”; // grid column name, same as db field or alias from sql
$col[“editable”] = true;
$col[“editoptions”][“defaultValue”]=$_SESSION[‘accounts_sak’];
array(“list”=>true, “add”=>false, “edit”=>true, “view”=>true, “bulkedit”=>false);
$cols[] = $col;

3 Answers
Abu Ghufran Staff answered 2 years ago

Best way to do this is to use on_update event. e.g.

$e["on_update"] = array("update_data", null, true);
$g->set_events($e);
function update_data($data)
{
$data["params"]["processed_by"] = $_SESSION["accounts_sak"];
}

Refer this link for more details:

https://www.gridphp.com/docs/grid-events/

_________________________
Abu Ghufran - Dev Team
Grid 4 PHP Framework
 
Michael Olson answered 2 years ago

will that update the field for only the row that I edited? Not the entire table right?

Michael Olson answered 2 years ago

Ooooh! Thank you that works perfectly!

Your Answer

15 + 2 =

Login with your Social Id:

OR, enter

Attach code here and paste link in question.
Attach screenshot here and paste link in question.



How useful was this discussion?

Click on a star to rate it!

Average rating 0 / 5. Vote count: 0

No votes so far! Be the first to rate it.

We are sorry that this post was not useful for you!

Let us improve this post!

Tell us how we can improve this post?