hidden field with concat value

Questionshidden field with concat value
Ced asked 8 months ago

Hello,

I trying to add a field to my grid that will automatically contains the value of a concatened chain

The hidden field uname should contains concat(‘firstname’,’.’,’lastname’)

Could you help me with this?

Thanks,

Ced

$col = array();
$col[“title”] = _HSElname;
$col[“name”] = “hsetest_lastname”;
$col[“formoptions”] = array(“elmsuffix”=>'<font color=red> *</font>’);
$col[“width”] = “20”;
$col[“search”] = true;
$col[“editable”] = true;
$cols[] = $col;

$col = array();
$col[“title”] = _HSEfname;
$col[“name”] = “hsetest_firstname”;
$col[“formoptions”] = array(“elmsuffix”=>'<font color=red> *</font>’);
$col[“width”] = “20”;
$col[“search”] = true;
$col[“editable”] = true;
$col[“editrules”] = array(“required”=>true);
$col[“sortable”] = true;
$col[“show”][“add”] = true;
$col[“show”][“list”] = true;
$cols[] = $col;

$col = array();
$col[“title”] = _HSEUname;
$col[“name”] = “hsetest_uname”;
$col[“width”] = “20”;
$col[“search”] = false;
$col[“editable”] = false;
$col[“sortable”] = false;
$col[“show”][“add”] = false;
$col[“show”][“list”] = false;
$cols[] = $col;

2 Answers
Abu Ghufran Staff answered 8 months ago

Hi,

You can do it using callback (on_insert) function. You need not to include this hidden field on grid. For more details, refer: https://www.gridphp.com/docs/grid-events/

$e["on_insert"] = array("add_data", null, true);
$g->set_events($e);

function add_data($data)
{
$data["params"]["hsetest_uname"] = $data["params"]["hsetest_firstname"] . "." . $data["params"]["hsetest_lastname"];
}
_________________________
Abu Ghufran - Dev Team
Grid 4 PHP Framework
 
Cedric answered 8 months ago

Thanks Abu, that works perfect

Your Answer

20 + 6 =

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?