Hi,
I need to have a field that is calculated by code from other fields of the record (yes, I know, do not save such things in the database, but AG makes it difficult to work with a database-clean-consciousness).
So I set the field in AG to be read only. The field id displayed in the generated application - but can not be changed.
I created a hook (_before-insert) that should fill that field of a new (and from changed) records. This does NOT work.
When I change the setting in AG and remove the read only flag, of course, I can change the value in the web - but now my hook code works as expected.
The same happens, when the field in AG is not readonly but hidden (hide in table/detail view) -> hook does not fill the field
I think this is a bug. The hook should work for all fields and not depend if a field if read only in AG (or not shown to the user).
Olaf
Bug 5.75: Read Only field not touched by hook _before_insert
Bug 5.75: Read Only field not touched by hook _before_insert
Some postings I was involved, you might find useful:
SingleEdit - Prevent concurrent edits on records; Field Permissions; Column-Value-Based-Permissions; Custom (error) message; Audit Log; Backup your database; Two Factor Authentication; Block brute force (failed) logins; Add 2nd SAVE CHANGES button; Place a search on details view
SingleEdit - Prevent concurrent edits on records; Field Permissions; Column-Value-Based-Permissions; Custom (error) message; Audit Log; Backup your database; Two Factor Authentication; Block brute force (failed) logins; Add 2nd SAVE CHANGES button; Place a search on details view
Re: Bug 5.75: Read Only field not touched by hook _before_insert
Hi Olaf,
this is not a bug but this is the way AppGini works. Readonly or hidden fields are not available for modification in your $data variable.
See this topic:
viewtopic.php?p=10195#p10188
Jan
this is not a bug but this is the way AppGini works. Readonly or hidden fields are not available for modification in your $data variable.
See this topic:
viewtopic.php?p=10195#p10188
- You can hide or lock those fields using JQuery instead but this is not secure enough, so you should implement additional validation in PHP.
- You can use SQL in your hooks
Jan
Kind regards,
<js />
My AppGini Blog:
https://appgini.bizzworxx.de/blog
You can help us helping you:
Please always put code fragments inside
AppGini 24.10 Revision 1579 + all AppGini Helper tools
<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 readabilityAppGini 24.10 Revision 1579 + all AppGini Helper tools
Re: Bug 5.75: Read Only field not touched by hook _before_insert
Hi Jan,
I hear your (and pbötcher's) word - but it's almost impossible to believe.
Why would AG hide fields from my in the backend (php, hooks)? Using JS is very unsafe....
I did try to use SQL in the hooks to grab something from the table and put in in that hidden/readonly field.
What about the primary key on the table - this is most likely hidden from view. When I want to use some trick (in the _after_insert hook probably), I still need that field.
In https://bigprof.com/appgini/help/advanc ... ore_insert unfortunately nothing is said that hidden/read only fields are inaccessible. .. Well, now I see it documented in the function info text (in the hooks file of the table)
So - can I access the contents of the primary key field .. when it's hidden/readonly? Do you know?
Olaf
I hear your (and pbötcher's) word - but it's almost impossible to believe.
Why would AG hide fields from my in the backend (php, hooks)? Using JS is very unsafe....
I did try to use SQL in the hooks to grab something from the table and put in in that hidden/readonly field.
What about the primary key on the table - this is most likely hidden from view. When I want to use some trick (in the _after_insert hook probably), I still need that field.
In https://bigprof.com/appgini/help/advanc ... ore_insert unfortunately nothing is said that hidden/read only fields are inaccessible. .. Well, now I see it documented in the function info text (in the hooks file of the table)
So - can I access the contents of the primary key field .. when it's hidden/readonly? Do you know?
Olaf
Some postings I was involved, you might find useful:
SingleEdit - Prevent concurrent edits on records; Field Permissions; Column-Value-Based-Permissions; Custom (error) message; Audit Log; Backup your database; Two Factor Authentication; Block brute force (failed) logins; Add 2nd SAVE CHANGES button; Place a search on details view
SingleEdit - Prevent concurrent edits on records; Field Permissions; Column-Value-Based-Permissions; Custom (error) message; Audit Log; Backup your database; Two Factor Authentication; Block brute force (failed) logins; Add 2nd SAVE CHANGES button; Place a search on details view