Customize SyliusFlowBundle render

2019-08-29 11:14发布

问题:

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?

回答1:

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}) }}