Page 1 of 1

Concat text + field + text in hook

Posted: 2017-11-01 14:08
by naturick
Hello, sorry for banal question

I would like to aucomatic insert concat value in a field acting on "before insert section" on hook.
At the same time I need that this field is read only for users...

SOME_TEXT + ['field1_value'] + SOME_OTHER_TEXT

I have tried many ways like:
$data['field'] = "TEXT" & $data['field1_value'] & "TEXT2" ;

but nothing.
Could you please help me?

Re: Concat text + field + text in hook

Posted: 2017-11-01 15:09
by AhmedBR
You need to make the field as Readonly in Appgini.

and use sql udpate to set the value in your database, something like this:

Code: Select all

sql("update `YOURTABLE` set `YOURFEILD` = 'THE VALUE YOU WANT' where `ID` = {$data['ID']}", $eo);

Re: Concat text + field + text in hook

Posted: 2017-11-02 07:02
by naturick
Thanks.
So you say there is no way to insert value on a field as "concat" between text and value from another field, by using expression like:

$data[field] = concat expression

The only way is by sql.

Re: Concat text + field + text in hook

Posted: 2017-11-02 07:24
by naturick
SOLVED
Easy as drink a glass of water:

$data['field'] = 'TEXT' . $data['field1_value'] . 'TEXT2';

Simply using . (dot)