SS4
I am trying to add a timestamp to form submissions written to the DB, using pointers from this thread.
Is there a built in method on a form object to get the date/time of the submission?
I am trying to manually set a form hiddenfield’s value in the FormAction, but cannot make it work…
//setting the date at creation works,
// however, I would prefer the timestamp to be when the submit handler fires
HiddenField::create('Date')->setValue(DBDatetime::now());
//I have tried the following methods in the FormAction, without success
public function submit($data, $form) {
//...
$form->setField('Date', DBDatetime::now());
$form->Fields()->getField('Date')->setValue(DBDatetime::now());
$submission = Contact::create();
$form->saveInto($submission);
$submission->write();
//...
}
Cheers,
Olly