1

I'm using Fuelux Wizard component for set up a wizard on my application. This is the HTML markup on my template:

<div class="wizard" data-initialize="wizard" id="myWizard">
    <ul class="steps">
        <li data-step="1" class="active"><span class="badge">1</span>Step 1<span class="chevron"></span></li>
        <li data-step="2"><span class="badge">2</span>Step 2<span class="chevron"></span></li>
        <li data-step="3"><span class="badge">3</span>Step 3<span class="chevron"></span></li>
    </ul>
    <div class="actions">
        <button class="btn btn-default btn-prev"><span class="glyphicon glyphicon-arrow-left"></span>Previous</button>
        <button class="btn btn-default btn-next" data-last="Complete">Next<span class="glyphicon glyphicon-arrow-right"></span></button>
    </div>
    <div class="step-content">
            <div class="step-pane active sample-pane" data-step="1">
                // here goes the firstStep
            </div>
            <div class="step-pane sample-pane " data-step="2">
                // here goes the secondStep
            </div>
            <div class="step-pane sample-pane" data-step="3">
                // here goes the thirdtStep
            </div>
    </div>
</div>

This is the displayAction method on ControllerStep:

public function displayAction(ProcessContextInterface $context)
{
    $entity = new Producto();
    $form = $this->createForm(new FirstStepFormType(), $entity);

    return $this->render('RPNIBundle:Producto:_paso1.html.twig', array(
                'entity' => $entity,
                'form' => $form->createView())
    );
}

How do I render the displayAction output where it should go? In this case where the text // here goes the firstStep is? How do I manage Previos/Next links in my template?

ReynierPM
  • 17,594
  • 53
  • 193
  • 363

1 Answers1

0

What did you mean about rendering? It seems that you already did it in your code snippet. As for Previous/Next links there are methods $context->getPreviousStep() and $context->getNextStep(), so in template you can do

{{ path('sylius_flow_display', {'scenarioAlias': 'sylius_flow', 'stepName': context.previous}) }}

Roman Kliuchko
  • 499
  • 4
  • 20
  • @roma-kliuchko, I'm getting this error when I try to go to second step `Step "second" not found in step history` any ideas? This is how I have the previos/next links: `{{ path('sylius_flow_display', {'scenarioAlias': 'RPNIScenario', 'stepName': 'first'}) }}` for previous which I think is wrong since it will go always to `first` step and this for next `{{ path('sylius_flow_forward', {'scenarioAlias': 'RPNIScenario', 'stepName': 'second'}) }}` which I think is wrong too since will go always to second step, so how do I go to next/previous and how to fix that error? – ReynierPM Oct 15 '14 at 11:40
  • @ReynierPM, sorry for late response. To get right links you need to pass `context` object to template and and use it in links' generation: `{{ path('sylius_flow_forward', {'scenarioAlias': 'RPNIScenario', 'stepName': context.previousStep}) }}` for previous step's link and same but with `context.nextStep` for next step's link. – Roman Kliuchko Oct 15 '14 at 20:49
  • @roma-kliuchko not worries about the delay I understand, I've not idea what you're talking about, can you take a look to my [step](https://gist.github.com/paquitodev/77b6a547232f5df4a619) class and see how `context` fit on it? – ReynierPM Oct 15 '14 at 21:27
  • @ReynierPM I meant that you need to pass `$context` to template: `return $this->render('RPNIBundle:Producto:_paso1.html.twig', array( 'entity' => $entity, 'form' => $form->createView(), 'context' => $context)` and generate links as I described above. );` – Roman Kliuchko Oct 15 '14 at 21:45
  • Ok, but I'm not doing nothing with this `$context` var, just setting it as a parameter, is that right? I tested and got this error `Step with name "context.second" does not exist` – ReynierPM Oct 15 '14 at 21:47
  • Also you didn't leave me the `displayAction` function here on [this](http://stackoverflow.com/questions/26348376/handling-a-complex-symfony2-form-with-multiple-entities-relationship/26348786?noredirect=1#comment41399846_26348786) comment – ReynierPM Oct 15 '14 at 22:01