Bug 5.75: Read Only field not touched by hook _before_insert

Please report bugs and any annoyances here. Kindly include all possible details: steps to reproduce, expected result, actual result, screenshots, ... etc.
Post Reply
User avatar
onoehring
AppGini Super Hero
AppGini Super Hero
Posts: 1156
Joined: 2019-05-21 22:42
Location: Germany
Contact:

Bug 5.75: Read Only field not touched by hook _before_insert

Post by onoehring » 2019-06-13 07:10

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

User avatar
jsetzer
AppGini Super Hero
AppGini Super Hero
Posts: 1807
Joined: 2018-07-06 06:03
Location: Kiel, Germany
Contact:

Re: Bug 5.75: Read Only field not touched by hook _before_insert

Post by jsetzer » 2019-06-13 08:00

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

  • 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
Best,
Jan
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

User avatar
onoehring
AppGini Super Hero
AppGini Super Hero
Posts: 1156
Joined: 2019-05-21 22:42
Location: Germany
Contact:

Re: Bug 5.75: Read Only field not touched by hook _before_insert

Post by onoehring » 2019-06-13 08:44

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) :evil:

So - can I access the contents of the primary key field .. when it's hidden/readonly? Do you know?

Olaf

Post Reply