- Work done on Form handling
This commit is contained in:
		
							parent
							
								
									a8a99f1852
								
							
						
					
					
						commit
						e4b4cdb818
					
				| @ -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); | ||||
|     } | ||||
|  | ||||
| @ -17,6 +17,8 @@ class FormContext implements FormContextInterface | ||||
|      | ||||
|     public ? ResponseInterface $response = null; | ||||
| 
 | ||||
|     protected int $action; | ||||
|      | ||||
|     public function __construct(ServerRequestInterface $request)  | ||||
|     { | ||||
|         $this->request = $request; | ||||
|  | ||||
| @ -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); | ||||
|             } | ||||
|         } | ||||
|     } | ||||
|  | ||||
| @ -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;   | ||||
| } | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user