Page 1 of 1

Auto Fill not storing data if hidden in DV

Posted: 2022-10-14 16:15
by rpierce
Hello,

I have an auto fill field "Project ID" which is coming from another table. I don't want to show while entering data. If the field is not hidden in DV the data is stored into the database. If the field is hidden in DV then no data is stored in the database. I'm probably missing something somewhere I hope one of you can help me.

Thank you,
Ray

Re: Auto Fill not storing data if hidden in DV

Posted: 2022-10-14 18:00
by AhmedBR
This is how I do it:
Keep it hidden in DV and update the database using sql in hooks after insert and after update if necessary.

Re: Auto Fill not storing data if hidden in DV

Posted: 2022-10-14 18:21
by rpierce
Thank you Ahmed,

But, I have no idea of how to write the sql statement to get that done. My sql skills are growing, but slowly I'm afraid.

Ray

Re: Auto Fill not storing data if hidden in DV

Posted: 2022-10-14 22:46
by rpierce
I would gladly purchase a library of Hooks code that could be modified for different purposes.

Re: Auto Fill not storing data if hidden in DV

Posted: 2022-10-15 12:08
by AhmedBR
I do not think there is a library of hooks,I am just an average coder myself, but I would be happy to help you with this one.
Just tell me the table names and the fields in question.

Re: Auto Fill not storing data if hidden in DV

Posted: 2022-10-15 17:44
by rpierce
Great!

'project' is the main Parent table and I want the 'project_id' field to appear in the database for the child table. 'audit' is the child to 'project' and 'findings' is the child to 'audit'. I also want the 'project_id' field data in the findings table. I have that set as an auto fill but it isn't being populated in the database either since I have it hidden in DV.

I'm sure this is confusing but I'll give you any more information you need.

Thanks for offering to help.

Ray

Re: Auto Fill not storing data if hidden in DV

Posted: 2022-10-15 18:53
by AhmedBR
Just need one more field name, the other field that causes the auto fill, as we are going to use it to get the sqlvalue of project_id

In other words project_id in the audit table is auto filled based on what field in the audit table?

Here is how it works, this way you can do it in other places if you need to:
First we get the value from the project table that is not auto filling:

Code: Select all

      $proid=sqlvalue("select `project_id` from `project` where `id` = {$data['THE FIELD THAT CAUSES the auto fill']}",$eo);
With the value in hand we update the other table:

Code: Select all

    	sql("update àudit` set `project_id` = $proid where `id` = {$data['id']}",$eo);
Both lines goes in after insert hook and after update hook in audit table.

Re: Auto Fill not storing data if hidden in DV

Posted: 2022-10-15 19:00
by AhmedBR
By the way the above will get the actual value, but in case you just need to make just a reference, then it is even simpler:
You just set the value as the other field.

Code: Select all


sql("update àudit` set `project_id` = `THE FIELD THAT CAUSES the auto FILL`  where `id` = {$data['id']}",$eo);

Since Appgini will always use id of the parent for all the fields, and show the values when the child is open.