- Worked with the files begin on the context part

This commit is contained in:
Dave M. 2021-03-09 15:27:54 +00:00
parent e75d997b02
commit 0d9db0470e
4 changed files with 21 additions and 8 deletions

View File

@ -6,8 +6,8 @@ class UiFile extends UiInput {
public string $token = "ui.file"; public string $token = "ui.file";
public array $attributes = [ public array $attributes = [
'class' => "ui-file", 'class' => "ui-file",
'type' => "file", 'type' => "file",
]; ];
} }

View File

@ -10,9 +10,13 @@ class FormContext implements FormContextInterface
public string $formName; public string $formName;
public bool $formSent; public bool $formSent;
public bool $formExecuted = false;
public array $values = []; public array $values = [];
public array $files = [];
public array $messages = []; public array $messages = [];
public ServerRequestInterface $request; public ServerRequestInterface $request;
@ -28,6 +32,8 @@ class FormContext implements FormContextInterface
} }
$this->values = $request->getParsedBody() ?: []; $this->values = $request->getParsedBody() ?: [];
$this->files = $request->getUploadedFiles() ?: [];
} }
public function valid() : bool public function valid() : bool
@ -40,7 +46,12 @@ class FormContext implements FormContextInterface
return true; return true;
} }
public function executed() : bool
{
return $this->formExecuted;
}
public function formSent() : bool public function formSent() : bool
{ {
return $this->formSent; return $this->formSent;

View File

@ -50,6 +50,8 @@ class FormHandler {
if ( $this->sent ) { if ( $this->sent ) {
if ( $this->form->validate($this->context) ) { if ( $this->form->validate($this->context) ) {
$this->executionStatus = $this->form->execute($this->context); $this->executionStatus = $this->form->execute($this->context);
$this->context->formExecuted = true;
} }
} }
} }

View File

@ -8,5 +8,5 @@ interface FormInterface
public function validate(FormContextInterface $context) : bool; public function validate(FormContextInterface $context) : bool;
public function execute(FormContextInterface $context) : void; public function execute(FormContextInterface $context) /* : mixed */;
} }