Skip to content

Commit

Permalink
v2.1.0
Browse files Browse the repository at this point in the history
Add optional session key parameter to the start method
Update stepped-form package to the 2.1.0
  • Loading branch information
lexalium committed Dec 30, 2023
1 parent 9cc41d0 commit ffd99fe
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 13 deletions.
7 changes: 5 additions & 2 deletions README.md
Expand Up @@ -117,7 +117,7 @@ composer require lexal/http-stepped-form
use Lexal\HttpSteppedForm\SteppedForm;

$form = new SteppedForm(
/* a base stepped form from the point 1 */,
/* a base stepped form from the step 1 */,
$formSettings,
$redirector,
$renderer,
Expand All @@ -131,7 +131,10 @@ composer require lexal/http-stepped-form
* Starts a new form session.
* Returns redirect response to the next step or URL after form finish.
*/
$form->start(/* an entity for initializing a form state */);
$form->start(
/* an entity to initialize a form state */,
/* unique session key is you need to split different sessions of one form */,
);

/* Renders step by its definition */
$form->render('key');
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Expand Up @@ -16,7 +16,7 @@
],
"require": {
"php": ">=8.1",
"lexal/stepped-form": "^2.0",
"lexal/stepped-form": "^2.1",
"symfony/http-foundation": "^5.4 || ^6.4 || ^7.0"
},
"require-dev": {
Expand Down
14 changes: 7 additions & 7 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions src/SteppedForm.php
Expand Up @@ -32,10 +32,10 @@ public function getEntity(): mixed
return $this->form->getEntity();
}

public function start(mixed $entity): Response
public function start(mixed $entity, string $sessionKey = BaseSteppedFormInterface::DEFAULT_SESSION_KEY): Response
{
try {
$key = $this->form->start($entity);
$key = $this->form->start($entity, $sessionKey);
} catch (SteppedFormException $exception) {
return $this->handleFormException($exception);
}
Expand Down
3 changes: 2 additions & 1 deletion src/SteppedFormInterface.php
Expand Up @@ -5,6 +5,7 @@
namespace Lexal\HttpSteppedForm;

use Lexal\SteppedForm\Exception\FormIsNotStartedException;
use Lexal\SteppedForm\SteppedFormInterface as BaseSteppedFormInterface;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;

Expand All @@ -20,7 +21,7 @@ public function getEntity(): mixed;
/**
* Starts a new form session and redirects to the first rendered step.
*/
public function start(mixed $entity): Response;
public function start(mixed $entity, string $sessionKey = BaseSteppedFormInterface::DEFAULT_SESSION_KEY): Response;

/**
* Returns a response with rendered step.
Expand Down

0 comments on commit ffd99fe

Please sign in to comment.