ZF2 Form data not updated from object after inputfilter object manipulation

429 Views Asked by At

I have a form filter that changes the value passed to it and returns this new value. After binding the entity, the object is updated as expected with the new value, but when showing form again, the old data (passed from the form) is still shown.

In the $form object, there are 2 data sets, $data (an array) and $object (the entity)... when binding, $data gets values from $object, when input filters are processed $object gets updated from the input filters, when showing form again, $data is shown (without updated changes to $object from input filters)...

How do I repopulate $data after determining validity (and thus running input filters)?

// $form->data == $entity Values (Original)
$form->bind($entity);
// $form->data updated to $formValues (from post)
$form->setData($formValues);
// $entity Values update to InputFilters & $formValues
if($form->isValid()) {
  // Saves the new $entity values
  $this->getEntityManager()->flush();
}
$response->setVariables(array(
  // $form->data shows $formValues but not updated InputFilter values 
  'form' => $form,
}
0

There are 0 best solutions below