Commit f9e7dbc2 authored by Bertrand Gauthier's avatar Bertrand Gauthier
Browse files

MultipageFormPlugin : possibilité d'omettre le formulaire lors de l'invoke

parent 68b89bbd
......@@ -120,12 +120,14 @@ class MultipageFormPlugin extends AbstractPlugin
/**
* Point d'entrée.
*
* @param MultipageForm $form Formulaire multi-pages
* @param MultipageForm|null $form Formulaire multi-pages
* @return self
*/
public function __invoke(MultipageForm $form)
public function __invoke(?MultipageForm $form = null)
{
$this->setForm($form);
if ($form !== null) {
$this->setForm($form);
}
return $this;
}
......@@ -349,14 +351,16 @@ class MultipageFormPlugin extends AbstractPlugin
*/
public function cancel()
{
if (!$this->cancelAction) {
$this->clearSession();
$fieldset = $this->fieldsetOrder[0]; // first step fieldset
$target = $this->fieldsetActions[$fieldset];
$this->setSessionActiveFieldsetName($fieldset);
}
else {
$target = $this->cancelAction;
$this->clearSession();
$target = $this->cancelAction;
if (!$target) {
if (isset($this->fieldsetOrder[0])) {
$fieldset = $this->fieldsetOrder[0]; // first step fieldset
$target = $this->fieldsetActions[$fieldset];
$this->setSessionActiveFieldsetName($fieldset);
}
}
return $this->redirect($target);
......@@ -621,6 +625,10 @@ class MultipageFormPlugin extends AbstractPlugin
*/
public function getCurrentFieldset()
{
if (null === $this->getForm()) {
throw new IllegalStateException('No form instance set.');
}
$fieldsetName = $this->getSessionActiveFieldsetName();
return $this->getFieldset($fieldsetName);
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment