- Work done on Form handling

This commit is contained in:
Dave Mc Nicoll 2020-02-07 16:38:54 -05:00
parent a8a99f1852
commit e4b4cdb818
4 changed files with 6 additions and 6 deletions

View File

@ -32,8 +32,6 @@ class Form implements Extension {
$this->formContext = new FormContext($this->request);
$context->pushFunction("form", [ $this, 'formClass' ]);
#$context->
}
public function form_csrf(string $field, string $value) {
@ -52,7 +50,7 @@ class Form implements Extension {
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);
}

View File

@ -17,6 +17,8 @@ class FormContext implements FormContextInterface
public ? ResponseInterface $response = null;
protected int $action;
public function __construct(ServerRequestInterface $request)
{
$this->request = $request;

View File

@ -31,7 +31,7 @@ class FormHandler {
if ( $this->sent ) {
if ( $this->form->validate($this->context) ) {
$this->form->save($this->context);
$this->form->run($this->context);
}
}
}

View File

@ -2,11 +2,11 @@
namespace Picea\Ui\Method;
interface FormInterface
interface FormInterface
{
public function initialize(FormContextInterface $context) : void;
public function validate(FormContextInterface $context) : bool;
public function save(FormContextInterface $context) : void;
public function run(FormContextInterface $context) : void;
}