PHP code example of peytz / wizard
1. Go to this page and download the library: Download peytz/wizard library . Choose the download type require .
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once ('vendor/autoload.php' );
peytz / wizard example snippets php
class_exists('Peytz\Wizard\Wizard' ));
php
namespace Vendor \Wizard ;
use Peytz \Wizard \Step ;
use Vendor \Wizard \Form \CustomFormType ;
class CustomStep extends Step
{
public function getFormType ()
{
return new CustomFormType();
}
}
php
namespace Vendor \Wizard ;
use Peytz \Wizard \Wizard ;
use Peytz \Wizard \ReportInterface ;
use Vendor \Wizard \CustomStep ;
class CustomWizard extends Wizard
{
public function __construct (ReportInterface $report)
{
parent ::__construct($report);
$this ->add(new CustomStep());
}
}
php
namespace Vendor \Wizard ;
use Peytz \Wizard \ReportInterface ;
class Report implements ReportInterface
{
}
php
namespace Vendor \Wizard ;
class Controller
{
protected $validator;
protected $wizard;
public function myAction ($stepIdentifier)
{
$step = $this ->wizard->get($stepIdentifier);
$form = $this ->createForm($step->getFormType(), $this ->wizard->getReport(), array (
'validation_groups' => array ($step->getName()),
));
if ($_POST) {
$form->bind($_POST);
if ($form->isValid()) {
$this ->wizard->process($step);
}
}
return array (
'form' => $form,
);
}
}