I have a custom plugin where I get a freeform submission by token. I woud like to change a value in this submission and resave the submission. When I try this the old form data gets overwritten.

$submission = Freeform::getInstance()->submissions->getSubmissionByToken($submissionToken);

$submission->setFormFieldValues(['customField' => $customFieldValue]);

// method 1, doesn't accept type submission, should be form     
// method 2, old data get's overwritten, current submissiontoken changes

1 Answer 1


It looks like setFormFieldValues() has an optional second parameter related to overriding values...

public function setFormFieldValues(array $values, bool $override = true)

So, changing...

$submission->setFormFieldValues(['customField' => $customFieldValue]);

... to...

$submission->setFormFieldValues(['customField' => $customFieldValue], false);

may help with the override issue.

  • Yes, this was the solution. I already had found this answer myself. No idea how I missed it. Thanks for your reply.
    – bartpulse
    Commented Mar 1, 2021 at 8:42

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.