Adding data on create

Adding data on create

nskwortsownskwortsow Posts: 120Questions: 0Answers: 0
edited November 2012 in Editor
Hi Allan,
on CREATE, I want to add data for a field (i.e. DateAdded(YMD))
This field should not be visible in the editor and should only be applied upon a NEW record (i.e. CREATE).
Any pointers?
N

Replies

  • nskwortsownskwortsow Posts: 120Questions: 0Answers: 0
    Also: for another field, I want to show information in the DataTable, but not in the editor (i.e. readonly).

    Please point me in the right direction.
  • allanallan Posts: 61,453Questions: 1Answers: 10,055 Site admin
    For the second one there is an example here:
    http://editor.datatables.net/release/DataTables/extras/Editor/examples/tableOnlyData.html

    For the first, I would actually suggest that you use SQL to do that. Simply set the value of the timestamp to current time on create. Depending on what SQL database you are using there are different ways of doing that (a 'insert' trigger).

    It could be done in Javascript with a hidden field, or in PHP by intercepting the submit and adding the required value in, but I'd suggest using the database since that is where the data must ensure its integrity.

    Allan
This discussion has been closed.