CraueFormFlowBundle icon indicating copy to clipboard operation
CraueFormFlowBundle copied to clipboard

Add additional Data to flow

Open ch3rm opened this issue 10 years ago • 2 comments

How can I add some inital data to a multi step form flow. I'd like to add the start-time (first call) and the end-time (submit). Any idea how to accomplish that?

ch3rm avatar Jan 24 '15 21:01 ch3rm

There's no built-in solution for this. You would need to save such data manually (but you can use the attached storage).

craue avatar May 19 '15 12:05 craue

Hi, I have the same need.

I have a 2 steps form. My last/2nd step is an optional step. I show it only if I find some duplication items in my database.

If there are, I ask the user if he/she really wants to add the new prescriber or not.

So, I use the skip parameter in my FormFlow class like this :

array(
	'label'		=> 'Confirmation',
	'skip' 		=> function($estimatedCurrentStepNumber, FormFlowInterface $flow) use (&$em) {
		$rp 	= $em->getRepository('AppBundle:Prescriber');

		# search if a prescriber already exists
		$qb = $rp->createQueryBuilder('p');
		$qb->where($qb->expr()->eq('p.rpps', ':rpps'))
			->setParameter('rpps', $flow->getFormData()->getRpps());

		$results = $qb->getQuery()->getResult();

		return ($estimatedCurrentStepNumber > 1 && empty($results)) ? true : false;
	}
)

But I don't know how to display in this step all the duplication items I found ($results).

I thought to add a form_options parameter and serialize my doubloons in an HiddenType field...

Is there a way to do it differently ? Maybe in the Controller action ?

eved42 avatar Dec 04 '17 09:12 eved42