craue/CraueFormFlowBundle — Issue #15: Problem uploading file
Author: madarco
Created: 2012-02-13 15:08:45+00:00
State: open

I have the following Entity (not Doctrine Entity, just a plain class):

class RegistrationEntity {
private $photo;
...

public function setPhoto($photo) {
if($photo instanceof UploadedFile) {
$this->photo = $photo->move('/tmp', 'foo.jpg')->getPathname();
}
else {
$this->photo = $photo;
}
}
}

With my action I'm trying to upload the photo on step 2 (of 3):

public function accountantAction() {
$values = new RegistrationEntity();

//Manage multi-step form:
$flow = $this->get('longtale.form.flow.registrationFlow'); // must match the flow's service id
$flow->bind($values);

$form = $flow->createForm($values);

if ($flow->isValid($form)) {
$flow->saveCurrentStepData();

if ($flow->nextStep()) {

// render form for next step
return array(
'form' => $flow->createForm($values)->createView(),
'flow' => $flow,
);
}

//All steps completed:
die(var_dump($values));

$flow->reset();
return $this->redirect($this->generateUrl('home')); // redirect when done
}

return array('form' => $form->createView(), 'flow' => $flow);
}

However in the next step the $photo property with the temp filename of the uploaded file get lost, I dump the entity and the value $photo is null (while the others are ok).

in postValidate e preBind events of my Flow class the value is present when I submit the step2 form, but it disappear in the next step.

Any clue?

Thanks!