This commit is contained in:
Dave M. 2022-11-29 19:48:28 +00:00
commit cd3cb18665
3 changed files with 13 additions and 5 deletions

View File

@ -79,6 +79,11 @@ class UiSelect extends UiElement implements Extension {
protected function isSelected($check, $value, bool $strict = true) : bool
{
if ( is_array($value) ) {
return in_array($check, $value, $strict);
}
return $strict ? $check === $value : $check == $value;
}
}

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,8 +38,8 @@ 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;
}
}
}