Hi all,
I've created a table with some hidden fields (it doesn't show in table view and detail view) and automatically populated it within the tablename_before_insert function, the function works just fine when I created a new record.
But when I updated the record and save it, the hidden field's value gets overwritten and becomes null.
Can anyone help with this problem?
Thanks
Hidden field's value get overwritten when updating record
Re: Hidden field's value get overwritten when updating record
Hi Edix,
Are you manually setting those column values using SQL in the insert hook? It is possible that the hidden values are still represented in the $data structure in the update hook, so by not setting it explicitly in the update hook, it is null and that is what is getting updated. Whatever you do to set the value in the insert, apply that in the before_update hook.
~Paul
Are you manually setting those column values using SQL in the insert hook? It is possible that the hidden values are still represented in the $data structure in the update hook, so by not setting it explicitly in the update hook, it is null and that is what is getting updated. Whatever you do to set the value in the insert, apply that in the before_update hook.
~Paul
Re: Hidden field's value get overwritten when updating record
Hi Paul,
I've found a workaround for this problem, I unhide the field in appgini and then hide it using jquery.
Maybe just like you said, the before_update set it to null.
I've found a workaround for this problem, I unhide the field in appgini and then hide it using jquery.
Maybe just like you said, the before_update set it to null.
Regards,
Edix
Edix
Re: Hidden field's value get overwritten when updating record
Hi,
if you hide fields in AG, they are not included in the $data e.g. in the _before_insert function.
Instead making fields visible in AG - you probably do not want people to be able to see those fields (which would essentially be possible using the console of the browser, when using jquery), I suggest the following: Use the tablename_after_insert to access the record in the database directly and then write the data you want to add to the "hidden" field. This way, no one would be able to interfere with the data. IN the after_insert just grab the $selectedID from the $data variable $data('selectedID') and use your own SQL to update the specific record.
Olaf
if you hide fields in AG, they are not included in the $data e.g. in the _before_insert function.
Instead making fields visible in AG - you probably do not want people to be able to see those fields (which would essentially be possible using the console of the browser, when using jquery), I suggest the following: Use the tablename_after_insert to access the record in the database directly and then write the data you want to add to the "hidden" field. This way, no one would be able to interfere with the data. IN the after_insert just grab the $selectedID from the $data variable $data('selectedID') and use your own SQL to update the specific record.
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
Re: Hidden field's value get overwritten when updating record
Hi Olaf,
Thanks for the explanation, I will try it and update the result as soon as I can.
Thanks for the explanation, I will try it and update the result as soon as I can.
Regards,
Edix
Edix