Forums: [SOLVED] Creating draft pages - Forums

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

[SOLVED] Creating draft pages Rate Topic: -----

#1 User is offline   BillyB 

  • Advanced Member
  • PipPipPip
  • Group: Members
  • Posts: 37
  • Joined: 23-September 16
  • Gender:Male

Posted 26 April 2019 - 11:42 PM

Hello,

I have an area that staff put in case notes. I have implemented an autosave via ajax to the edit page. I would like to do this on the add page but of course do not have a record ID yet to make sure the proper record is updated. I was thinking of implementing some type of draft page that gets saved via ajax and then when the staff member actually hits add record on the add page it gets added normally. Has anyone tackled this?

Thanks for any input.
0

#2 User is offline   admin 

  • Administrator
  • PipPipPip
  • Group: Admin
  • Posts: 16399
  • Joined: 03-February 03
  • Gender:Male

Posted 28 April 2019 - 07:18 PM

Something like this can be done. Since autosave only works on the edit you will have to create a draft/temporary record and redirect user to that page.

1. Add a new yes/no field to the table in question, name it "draft" for instance. Draft records will have 'yes' in this field, actual records will have 'no' there. Make sure that on the list page only actual records are displayed.

select ...
from ...
WHERE draft='no'


2. Add page: BeforeProcess event. Create a new record, set draft='yes', redirect user to the Edit page of this record.

3. When record is saved on the Edit page add the following to BeforeEdit event:

$values["draft"]='false';

Best regards,
Sergey Kornilov
0

#3 User is offline   BillyB 

  • Advanced Member
  • PipPipPip
  • Group: Members
  • Posts: 37
  • Joined: 23-September 16
  • Gender:Male

Posted 30 April 2019 - 10:29 PM

Thanks Sergey!

I will try this.

Billy
0

#4 User is offline   BillyB 

  • Advanced Member
  • PipPipPip
  • Group: Members
  • Posts: 37
  • Joined: 23-September 16
  • Gender:Male

Posted 01 May 2019 - 01:41 AM

It works the way you said. I sorted the list page with tabs. One shows Drafts and the other Published.

Before record added (add page)
$values['Status']='Draft';
return true;


Before record added (edit page)
$values["Status"]='Published';
return true;


After record added (add page)
header("Location: tCaseNote_edit.php?editid1=".$values['ID']);
exit();


The only way I know to save the record on the add page is by forcing a save click to Javascript onload event
$("#saveButton1").click();


Is there a better way to do this? It is not that smooth.
0

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users