- Work done on Form handling

This commit is contained in:
Dave Mc Nicoll committed 2020-02-07 16:38:54 -05:00
1 parent a8a99f1852
commit e4b4cdb818
4 files changed
+5 -5

No files matched your search

+1 -3
View File
@@ -32,8 +32,6 @@ class Form implements Extension {
$this->formContext = new FormContext($this->request); $this->formContext = new FormContext($this->request);
$context->pushFunction("form", [ $this, 'formClass' ]); $context->pushFunction("form", [ $this, 'formClass' ]);
#$context->
} }
public function form_csrf(string $field, string $value) { public function form_csrf(string $field, string $value) {
@@ -52,7 +50,7 @@ class Form implements Extension {
return $value; return $value;
} }
public function formClass(FormInterface $form, ? FormContext $formContext = null) public function formClass(FormInterface $form, ? FormContext $formContext = null) : FormHandler
{ {
return new FormHandler($this->request, $form, $formContext ?: $this->formContext); return new FormHandler($this->request, $form, $formContext ?: $this->formContext);
} }
+2
View File
@@ -17,6 +17,8 @@ class FormContext implements FormContextInterface
public ? ResponseInterface $response = null; public ? ResponseInterface $response = null;
protected int $action;
public function __construct(ServerRequestInterface $request) public function __construct(ServerRequestInterface $request)
{ {
$this->request = $request; $this->request = $request;
+1 -1
View File
@@ -31,7 +31,7 @@ class FormHandler {
if ( $this->sent ) { if ( $this->sent ) {
if ( $this->form->validate($this->context) ) { if ( $this->form->validate($this->context) ) {
$this->form->save($this->context); $this->form->run($this->context);
} }
} }
} }
+1 -1
View File
@@ -8,5 +8,5 @@ interface FormInterface
public function validate(FormContextInterface $context) : bool; public function validate(FormContextInterface $context) : bool;
public function save(FormContextInterface $context) : void; public function run(FormContextInterface $context) : void;
} }