Is there a way you could cause a date field to be blank immediately after the Save as Copy function is used?
I have a table with several children tables. Project managers enter information for a daily report. Often much of the information is the same from day to day so we use the Save as Copy function.
The problem I would like to resolve is the creation of records with incorrect dates. Sometimes when a person does a Save as Copy, they jump right in to editing what they need to change and then save the record without remembering to change the date. The date field is required so if they tried to save the record with a blank date the system would yell at them.
Any cool code to make this happen??
Ray
Make field go blank after Save As Copy
Re: Make field go blank after Save As Copy
Try this in your tablename.php in hooks folder, insert this code inside the function "tablename_after_insert":
After Save as Copy is clicked the new
Code: Select all
$source_id = makeSafe($_REQUEST['SelectedID']);
if($source_id) {
$date = sqlValue("SELECT `date` FROM `tableNameHere` WHERE `id`='{$source_id}'");
update('tableNameHere', ['date' => null], ['id' => $data['selectedID']]);
}
Re: Make field go blank after Save As Copy
Hi Alisson,
I tried your suggestion with no luck. The new record continues to have the same date as to copied record.
I tried your suggestion with no luck. The new record continues to have the same date as to copied record.