If you're a new user of AppGini, feel free to ask general usage questions, or look for answers here.
-
devedix
- Veteran Member
- Posts: 30
- Joined: 2021-04-20 10:44
Post
by devedix » 2021-05-05 04:28
Hi all,
I try to make an autofill field in the before insert function in the hooks/table-name.php
Code: Select all
$data['prefix'] = 'DO/Company/'.date('m');
But it only returns 'DO/Company/' without the month
Is there something wrong with my code?
Thanks
Regards,
Edix
-
jsetzer
- AppGini Super Hero
- Posts: 1817
- Joined: 2018-07-06 06:03
- Location: Kiel, Germany
-
Contact:
Post
by jsetzer » 2021-05-05 04:38
Does $data contain a prefix-value?
prefix field must not be readonly.
For narrowing down I would debug the contents of $data in before_insert hook to see if there is any $data['prefix'] array item at all:
SORRY, I was too fast. My answer is not helpful as you said, your function DOES return something. But I cannot delete this post. Please ignore it.
Kind regards,
<js />
My AppGini Blog:
https://appgini.bizzworxx.de/blog
You can help us helping you:
Please always put code fragments inside
[code]...[/code]
blocks for better readability
AppGini 24.10 Revision 1579 + all AppGini Helper tools
-
devedix
- Veteran Member
- Posts: 30
- Joined: 2021-04-20 10:44
Post
by devedix » 2021-05-05 05:16
Hi @jsetzer,
Thanks for the fast response.
Yes, it does return the string but without the month.
By the way, I really like the AppginiHelper Javascript library.
Nice work.
Regards,
Edix
-
pbottcher
- AppGini Super Hero
- Posts: 1638
- Joined: 2018-04-01 10:12
Post
by pbottcher » 2021-05-05 05:52
Hi,
I'm not sure, but I think you cannot use the hooks to manipultate autofill fields as they are picked up from the first field that points to your lookup record. If you want to do that, you will need to change the field to a read-only field and the approriate type and calc your value manually.
Any help offered comes with the best of intentions. Use it at your own risk. In any case, please make a backup of your existing environment before applying any changes.
-
devedix
- Veteran Member
- Posts: 30
- Joined: 2021-04-20 10:44
Post
by devedix » 2021-05-05 06:55
Hi @pböttcher,
Thanks for the answer, I will try your suggestion.
Regards,
Edix
-
devedix
- Veteran Member
- Posts: 30
- Joined: 2021-04-20 10:44
Post
by devedix » 2021-05-05 07:32
Hi all,
Just want to update you, I've found out the problem.
This is really embarrassing, a silly beginner mistake.
The reason why the month did not show up because of the max-length of the field.
After I increase the max-length of the field, the code works just fine.
Thanks again for all your support.
Regards,
Edix