Giter VIP home page Giter VIP logo

wizard's Introduction

nette/forms wizard

Build Status

Installation

Composer

composer require contributte/forms-wizard

Config

extensions:
    - Contributte\FormWizard\DI\WizardExtension

Usage

Component

use Nette\Application\UI\Form;

class Wizard extends Contribute\FormWizard\Wizard {

    protected function finish(): void 
    {
        $values = $this->getValues();
    }

    protected function createStep1(): Form 
    {
        $form = $this->createForm();

        $form->addText('name', 'User name')
            ->setRequired();

        $form->addSubmit(self::NEXT_SUBMIT_NAME, 'Next');

        return $form;
    }

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

        $form->addText('email', 'Email')
            ->setRequired();

        $form->addSubmit(self::PREV_SUBMIT_NAME, 'Back');
        $form->addSubmit(self::FINISH_SUBMIT_NAME, 'Register');

        return $form;
    }
}
services:
    - Wizard

Presenter

final class HomepagePresenter extends Nette\Application\UI\Presenter {

    /** @var Wizard @inject */
    public $wizard;
    
    public function handleChangeStep(int $step): void 
    {    
        $this['wizard']->setStep($step);
        
        $this->redirect('wizard'); // Optional, hides parameter from URL
    }

    protected function createComponentWizard(): Wizard 
    {
        return $this->wizard;
    }

}

Template

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

wizard's People

Contributors

adaamz avatar valicek1 avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.