Compare commits
5
Commits
0a7b1cdc12
...
v1.0.0
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a34ebaf0df | ||
|
|
388b2a70f8 | ||
|
|
195586a078 | ||
|
|
5e9ad29f3c | ||
|
|
1991122c32 |
No files matched your search
+1
-1
@@ -99,7 +99,7 @@ class Ui extends UiElement implements Extension {
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case in_array('time', $options):
|
case in_array('time', $options):
|
||||||
$input = new UiText();
|
$input = new UiTime();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case in_array('url', $options):
|
case in_array('url', $options):
|
||||||
|
|||||||
+3
-2
@@ -68,7 +68,8 @@ class UiForm extends UiElement implements Extension {
|
|||||||
|
|
||||||
public function buildHtml(string $method = "get", string $name = "", string $action = "", array $attributes = []) : string
|
public function buildHtml(string $method = "get", string $name = "", string $action = "", array $attributes = []) : string
|
||||||
{
|
{
|
||||||
$method = strtolower($method);
|
# Method passed in arguments take precedents over options
|
||||||
|
$method = strtolower($attributes['method'] ?? $method);
|
||||||
|
|
||||||
$this->option('tag-type', 'single');
|
$this->option('tag-type', 'single');
|
||||||
|
|
||||||
@@ -77,7 +78,7 @@ class UiForm extends UiElement implements Extension {
|
|||||||
unset($this->attributes['class']);
|
unset($this->attributes['class']);
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->attributes([ 'method' => $method, 'action' => $action ] + $attributes);
|
$this->attributes([ 'action' => $action, 'method' => $method, ] + $attributes);
|
||||||
|
|
||||||
if ( $method !== "get" ) {
|
if ( $method !== "get" ) {
|
||||||
|
|
||||||
|
|||||||
@@ -51,9 +51,15 @@ class FormContext implements FormContextInterface
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$this->fillValues();
|
||||||
|
|
||||||
$this->files = $request->getUploadedFiles() ?: [];
|
$this->files = $request->getUploadedFiles() ?: [];
|
||||||
|
|
||||||
|
$this->initialize();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function initialize() : void {}
|
||||||
|
|
||||||
public function valid() : bool
|
public function valid() : bool
|
||||||
{
|
{
|
||||||
foreach($this->messages as $message) {
|
foreach($this->messages as $message) {
|
||||||
@@ -67,7 +73,7 @@ class FormContext implements FormContextInterface
|
|||||||
|
|
||||||
public function executed() : bool
|
public function executed() : bool
|
||||||
{
|
{
|
||||||
return $this->formExecuted;
|
return $this->formExecutionStatus === false ? false : $this->formExecuted;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function formSent() : bool
|
public function formSent() : bool
|
||||||
@@ -142,4 +148,16 @@ class FormContext implements FormContextInterface
|
|||||||
{
|
{
|
||||||
$this->messages[] = $message;
|
$this->messages[] = $message;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected function fillValues() : void
|
||||||
|
{
|
||||||
|
# Skipping overrides of this particular class vars as a security measure
|
||||||
|
$skipping = array_keys(array_change_key_case(get_class_vars(FormContext::class), CASE_LOWER));
|
||||||
|
|
||||||
|
foreach($this->values as $property => $value) {
|
||||||
|
if ( ! in_array(strtolower($property), $skipping) && property_exists($this, $property)) {
|
||||||
|
$this->$property = $value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Reference in new issue
Block a user