【问题标题】:Customize SyliusFlowBundle render自定义 SyliusFlowBundle 渲染
【发布时间】:2014-10-15 02:07:08
【问题描述】:

我正在使用 Fuelux 向导组件在我的应用程序上设置向导。这是我模板上的 HTML 标记:

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

这是ControllerStep 上的displayAction 方法:

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

如何将displayAction 输出渲染到应该去的地方?在这种情况下,文本// here goes the firstStep 在哪里?如何管理模板中的Previos/Next 链接?

【问题讨论】:

    标签: php symfony symfony-forms sylius


    【解决方案1】:

    你说的渲染是什么意思?看来您已经在代码 sn-p 中做到了。至于Previous/Next 链接有$context-&gt;getPreviousStep()$context-&gt;getNextStep() 方法,所以在模板中你可以这样做

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

    【讨论】:

    • @roma-kliuchko,当我尝试进入第二步时出现此错误Step "second" not found in step history 有什么想法吗?这就是我获得 previos/next 链接的方式:{{ path('sylius_flow_display', {'scenarioAlias': 'RPNIScenario', 'stepName': 'first'}) }} for previous 我认为这是错误的,因为它总是会转到 first step 而这对于下一个 {{ path('sylius_flow_forward', {'scenarioAlias': 'RPNIScenario', 'stepName': 'second'}) }} 我认为也是错误的,因为总是会转到第二个步骤,那么我该如何转到下一个/上一个以及如何修复该错误?
    • @ReynierPM,抱歉回复晚了。要获得正确的链接,您需要将 context 对象传递给模板并在链接的生成中使用它:{{ path('sylius_flow_forward', {'scenarioAlias': 'RPNIScenario', 'stepName': context.previousStep}) }} 用于上一步的链接,但context.nextStep 用于下一步的链接。
    • @roma-kliuchko 不用担心延迟我理解,我不知道你在说什么,你能看看我的step 课程,看看context 是否适合在上面吗?
    • @ReynierPM 我的意思是你需要将$context 传递给模板:return $this-&gt;render('RPNIBundle:Producto:_paso1.html.twig', array( 'entity' =&gt; $entity, 'form' =&gt; $form-&gt;createView(), 'context' =&gt; $context) 并生成我上面描述的链接。 );`
    • 好的,但是我没有对这个$context var 做任何事情,只是将它设置为参数,对吗?我测试并得到了这个错误Step with name "context.second" does not exist
    猜你喜欢
    • 2022-01-10
    • 2013-07-27
    • 2017-06-09
    • 2012-08-25
    • 1970-01-01
    • 2017-11-24
    • 2013-09-25
    • 2011-07-14
    • 1970-01-01
    相关资源
    最近更新 更多