Skip to content

Documentation - How to use values from previous step? #10

@patrickkusebauch

Description

@patrickkusebauch

Hello,
have used the template for latte used in the quickstart.

<div n:wizard="wizard">
    <ul n:if="!$wizard->isSuccess()">
        <li n:foreach="$wizard->steps as $step" n:class="$wizard->isDisabled($step) ? disabled, $wizard->isActive($step) ? active">
            <a n:tag-if="$wizard->useLink($step)" n:href="changeStep! $step">{$step}</a>
        </li>
    </ul>

    {step 1}
        {control $form}
    {/step}

    {step 2}
        {control $form}
    {/step}

    {step success}
        Registration was successful
    {/step}
</div>

However, whenever I reference a value from a previous step in the Component like this:

            protected function createStep2(): Form
            {
                $values = $this->getValues();
                $form   = $this->createForm();

                if($values->seasonDesc === 'personal') {
                    //conditional form based on values from the first step
                   }
            }

I get Notice: Undefined property: Nette\Utils\ArrayHash::{$nameOfProperty} even though I know the property should exist since it was created in the previous step.

This is the whole point of a wizard for me, that I can change the next step's form base on the values from the previous step. So is there any canonical way to do this other than always calling $values->offsetExists('seasonDesc')?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions