- Added some more information into the form context whether a form was sent, and what was it's return value (if there was any)

This commit is contained in:
Dave Mc Nicoll 2022-10-10 15:30:15 +00:00
parent 164a27d267
commit 1f5d38a8b9
2 changed files with 8 additions and 5 deletions

View File

@ -13,6 +13,8 @@ class FormContext implements FormContextInterface
public bool $formExecuted = false;
public /*mixed*/ $formExecutionStatus = null;
public array $values = [];
public array $files = [];
@ -64,7 +66,7 @@ class FormContext implements FormContextInterface
public function formSent() : bool
{
$valid = true;
$valid = in_array($this->request->getMethod(), [ 'POST', 'PUT', 'PATCH', 'DELETE', ]);
if ( ! $this->skipCsrf && ($this->formName ?? false) ) {
$token = $this->get('picea-ui-form')[$this->formName] ?? false;

View File

@ -13,7 +13,7 @@ class FormHandler {
public bool $validateCsrfToken = true;
public ? bool $executionStatus = null;
public /* mixed */ $executionStatus = null;
public ? bool $validationStatus = null;
@ -38,7 +38,7 @@ class FormHandler {
$this->context = method_exists($form, 'getContext') ? $form->getContext($request) : new FormContext($request);
}
$this->request->context = $this->context;
$this->request->withAttribute('picea.context', $this->context);
$this->initialize();
}
@ -49,7 +49,8 @@ class FormHandler {
if ( $this->sent && $this->context->formSent() ) {
if ( $this->validationStatus = $this->form->validate($this->context) ) {
$this->executionStatus = $this->form->execute($this->context);
$this->context->formExecutionStatus = $this->executionStatus = $this->form->execute($this->context);
$this->context->formExecuted = true;
}
}
}