How to handle DB-fields which are not in the form?
How to handle DB-fields which are not in the form?
Each of my tables contain the fields : createDate, modifiedDate, modifyUser, deleted.
I don't put these fields in my form and they shoud be modified in the following way:
- NEW : createDate and modifiedDate are set to ToDay
- EDIT : modifiedDate is set to ToDay
- DELETE: modifiedDate is set to ToDay, deleted is set to 1
In all three situations modifyUser should be set to the id of the actual.
How can I arrange it, that the above rules are functioning?
This question has an accepted answers - jump to answer
This discussion has been closed.
Answers
Are you using the PHP or .NET libraries provided for Editor? If so, the
set()
method and alsosetValue()
are what you are looking for here.For example you might have:
The .NET libraries have similar options.
The other option is to use your database to to it with triggers.
Regards,
Allan
Hi Allen,
Thanks, this solved my question for the fields "createDate" and "modifiedDate", however not the question for the field "deleted". I use a so called "soft"-delete, meaning that I put the row to deleted (by changing the value from 0 to 1) instead of really deleting the row.
At the moment I do it by showing the field "deleted" so the user has to change this value to 1. However, it would be more natural for the user to use the "delete"-button. As far as I see, the result of the "delete"-button is now a hard delete, meaning the record will be removed from the table.
Can you give me a glue or is my wish not possible at the moment?
Regards, Niek.
Hi,
For a soft delete what you actually want to do is use an edit rather than the Editor delete command (since really you are just editing the row's data!).
For this you would set up a separate Editor instance that would just set the value of the field that indicates the delete and submit that. You could have Editor show the confirm message (using
message()
if you wanted, or just have it immediately submit).Allan
Hi Allen,
In fact a soft delete is, at least with me, used quit a lot. I use it to keep info from the past for data-integrity.
As you can see above, I solved it already in your manner. However it need two edit-situations and extra code (-> two js- and two php-programs) for quite a lot of my tables.
Would it be possible for you to change the code as follows:
Regards, Niek.
Thanks for the suggestion - I'll certainly look into this as I like soft deletes myself. It won't be something that will make it into Editor 1.5, but I've added it to my list of features for future versions.
Regards,
Allan