@@ -2,8 +2,8 @@ |
||
| 2 | 2 | |
| 3 | 3 | namespace Helmut\Forms; |
| 4 | 4 | |
| 5 | -use Helmut\Forms\Utility\Str; |
|
| 6 | 5 | use Helmut\Forms\Utility\Reflect; |
| 6 | +use Helmut\Forms\Utility\Str; |
|
| 7 | 7 | |
| 8 | 8 | abstract class Field { |
| 9 | 9 | |
@@ -52,7 +52,9 @@ discard block |
||
| 52 | 52 | |
| 53 | 53 | public function setValueFromModel($model) |
| 54 | 54 | { |
| 55 | - if (property_exists($model, $this->name)) $this->value = $model->{$this->name}; |
|
| 55 | + if (property_exists($model, $this->name)) { |
|
| 56 | + $this->value = $model->{$this->name}; |
|
| 57 | + } |
|
| 56 | 58 | } |
| 57 | 59 | |
| 58 | 60 | public function setValueFromRequest($request) |
@@ -62,7 +64,9 @@ discard block |
||
| 62 | 64 | |
| 63 | 65 | public function fillModelWithValue($model) |
| 64 | 66 | { |
| 65 | - if (property_exists($model, $this->name)) $model->{$this->name} = $this->value; |
|
| 67 | + if (property_exists($model, $this->name)) { |
|
| 68 | + $model->{$this->name} = $this->value; |
|
| 69 | + } |
|
| 66 | 70 | } |
| 67 | 71 | |
| 68 | 72 | public function validateRequired() |
@@ -31,7 +31,9 @@ discard block |
||
| 31 | 31 | |
| 32 | 32 | public function setValueFromModel($model) |
| 33 | 33 | { |
| 34 | - if (property_exists($model, $this->name)) $this->value = $model->{$this->name}; |
|
| 34 | + if (property_exists($model, $this->name)) { |
|
| 35 | + $this->value = $model->{$this->name}; |
|
| 36 | + } |
|
| 35 | 37 | } |
| 36 | 38 | |
| 37 | 39 | public function setValueFromRequest($request) |
@@ -41,7 +43,9 @@ discard block |
||
| 41 | 43 | |
| 42 | 44 | public function fillModelWithValue($model) |
| 43 | 45 | { |
| 44 | - if (property_exists($model, $this->name)) $model->{$this->name} = $this->value; |
|
| 46 | + if (property_exists($model, $this->name)) { |
|
| 47 | + $model->{$this->name} = $this->value; |
|
| 48 | + } |
|
| 45 | 49 | } |
| 46 | 50 | |
| 47 | 51 | public function validate() |
@@ -41,7 +41,9 @@ discard block |
||
| 41 | 41 | |
| 42 | 42 | public function setValueFromModel($model) |
| 43 | 43 | { |
| 44 | - if (property_exists($model, $this->name)) $this->value = $model->{$this->name}; |
|
| 44 | + if (property_exists($model, $this->name)) { |
|
| 45 | + $this->value = $model->{$this->name}; |
|
| 46 | + } |
|
| 45 | 47 | } |
| 46 | 48 | |
| 47 | 49 | public function setValueFromRequest($request) |
@@ -51,7 +53,9 @@ discard block |
||
| 51 | 53 | |
| 52 | 54 | public function fillModelWithValue($model) |
| 53 | 55 | { |
| 54 | - if (property_exists($model, $this->name)) $model->{$this->name} = $this->value; |
|
| 56 | + if (property_exists($model, $this->name)) { |
|
| 57 | + $model->{$this->name} = $this->value; |
|
| 58 | + } |
|
| 55 | 59 | } |
| 56 | 60 | |
| 57 | 61 | public function validate() |
@@ -31,7 +31,9 @@ discard block |
||
| 31 | 31 | |
| 32 | 32 | public function setValueFromModel($model) |
| 33 | 33 | { |
| 34 | - if (property_exists($model, $this->name)) $this->value = $model->{$this->name}; |
|
| 34 | + if (property_exists($model, $this->name)) { |
|
| 35 | + $this->value = $model->{$this->name}; |
|
| 36 | + } |
|
| 35 | 37 | } |
| 36 | 38 | |
| 37 | 39 | public function setValueFromRequest($request) |
@@ -41,7 +43,9 @@ discard block |
||
| 41 | 43 | |
| 42 | 44 | public function fillModelWithValue($model) |
| 43 | 45 | { |
| 44 | - if (property_exists($model, $this->name)) $model->{$this->name} = $this->value; |
|
| 46 | + if (property_exists($model, $this->name)) { |
|
| 47 | + $model->{$this->name} = $this->value; |
|
| 48 | + } |
|
| 45 | 49 | } |
| 46 | 50 | |
| 47 | 51 | public function validateRequired() |
@@ -10,6 +10,9 @@ |
||
| 10 | 10 | protected $value = ''; |
| 11 | 11 | protected $value_confirmation = ''; |
| 12 | 12 | |
| 13 | + /** |
|
| 14 | + * @param string $value |
|
| 15 | + */ |
|
| 13 | 16 | public function hash($value) |
| 14 | 17 | { |
| 15 | 18 | if (strlen($value) === 0) { |
@@ -31,7 +31,9 @@ discard block |
||
| 31 | 31 | |
| 32 | 32 | public function setValueFromModel($model) |
| 33 | 33 | { |
| 34 | - if (property_exists($model, $this->name)) $this->value = $model->{$this->name}; |
|
| 34 | + if (property_exists($model, $this->name)) { |
|
| 35 | + $this->value = $model->{$this->name}; |
|
| 36 | + } |
|
| 35 | 37 | } |
| 36 | 38 | |
| 37 | 39 | public function setValueFromRequest($request) |
@@ -41,7 +43,9 @@ discard block |
||
| 41 | 43 | |
| 42 | 44 | public function fillModelWithValue($model) |
| 43 | 45 | { |
| 44 | - if (property_exists($model, $this->name)) $model->{$this->name} = $this->value; |
|
| 46 | + if (property_exists($model, $this->name)) { |
|
| 47 | + $model->{$this->name} = $this->value; |
|
| 48 | + } |
|
| 45 | 49 | } |
| 46 | 50 | |
| 47 | 51 | public function validateRequired() |
@@ -31,7 +31,9 @@ discard block |
||
| 31 | 31 | |
| 32 | 32 | public function setValueFromModel($model) |
| 33 | 33 | { |
| 34 | - if (property_exists($model, $this->name)) $this->value = $model->{$this->name}; |
|
| 34 | + if (property_exists($model, $this->name)) { |
|
| 35 | + $this->value = $model->{$this->name}; |
|
| 36 | + } |
|
| 35 | 37 | } |
| 36 | 38 | |
| 37 | 39 | public function setValueFromRequest($request) |
@@ -41,7 +43,9 @@ discard block |
||
| 41 | 43 | |
| 42 | 44 | public function fillModelWithValue($model) |
| 43 | 45 | { |
| 44 | - if (property_exists($model, $this->name)) $model->{$this->name} = $this->value; |
|
| 46 | + if (property_exists($model, $this->name)) { |
|
| 47 | + $model->{$this->name} = $this->value; |
|
| 48 | + } |
|
| 45 | 49 | } |
| 46 | 50 | |
| 47 | 51 | public function validateRequired() |
@@ -353,7 +353,7 @@ discard block |
||
| 353 | 353 | */ |
| 354 | 354 | public function completed($name = null) |
| 355 | 355 | { |
| 356 | - if($this->submitted($name) && $this->valid()) { |
|
| 356 | + if ($this->submitted($name) && $this->valid()) { |
|
| 357 | 357 | $this->broadcast('completed'); |
| 358 | 358 | return true; |
| 359 | 359 | } |
@@ -501,7 +501,7 @@ discard block |
||
| 501 | 501 | $errors = []; |
| 502 | 502 | |
| 503 | 503 | foreach ($this->fields as $field) { |
| 504 | - foreach($field->errors() as $error) { |
|
| 504 | + foreach ($field->errors() as $error) { |
|
| 505 | 505 | $errors[] = $error; |
| 506 | 506 | } |
| 507 | 507 | } |
@@ -623,8 +623,8 @@ discard block |
||
| 623 | 623 | { |
| 624 | 624 | $config = $this->templateConfig($template); |
| 625 | 625 | |
| 626 | - if ( isset($config['plugins']) && is_array($config['plugins'])) { |
|
| 627 | - foreach($config['plugins'] as $key => $plugin) { |
|
| 626 | + if (isset($config['plugins']) && is_array($config['plugins'])) { |
|
| 627 | + foreach ($config['plugins'] as $key => $plugin) { |
|
| 628 | 628 | if (is_array($plugin)) { |
| 629 | 629 | $this->addPlugin($key, $plugin); |
| 630 | 630 | } else { |
@@ -644,8 +644,8 @@ discard block |
||
| 644 | 644 | { |
| 645 | 645 | $config = $this->templateConfig($template); |
| 646 | 646 | |
| 647 | - if ( isset($config['plugins']) && is_array($config['plugins'])) { |
|
| 648 | - foreach($config['plugins'] as $plugin) { |
|
| 647 | + if (isset($config['plugins']) && is_array($config['plugins'])) { |
|
| 648 | + foreach ($config['plugins'] as $plugin) { |
|
| 649 | 649 | $this->removePlugin($plugin); |
| 650 | 650 | } |
| 651 | 651 | } |
@@ -682,7 +682,7 @@ discard block |
||
| 682 | 682 | foreach ($field->errors() as $error => $parameters) { |
| 683 | 683 | |
| 684 | 684 | if ($error == 'userDefined') { |
| 685 | - foreach($parameters as $message) { |
|
| 685 | + foreach ($parameters as $message) { |
|
| 686 | 686 | $properties['errors'][] = ['error' => $message]; |
| 687 | 687 | } |
| 688 | 688 | } else { |
@@ -691,7 +691,7 @@ discard block |
||
| 691 | 691 | |
| 692 | 692 | $message = $this->translate($error, $field); |
| 693 | 693 | |
| 694 | - foreach($parameters as $key => $value) { |
|
| 694 | + foreach ($parameters as $key => $value) { |
|
| 695 | 695 | if (is_object($value) && method_exists($value, '__toString')) { |
| 696 | 696 | $value = (string) $value; |
| 697 | 697 | } |
@@ -976,7 +976,7 @@ discard block |
||
| 976 | 976 | */ |
| 977 | 977 | private function broadcast($event, $params = []) |
| 978 | 978 | { |
| 979 | - foreach($this->plugins as $plugin) { |
|
| 979 | + foreach ($this->plugins as $plugin) { |
|
| 980 | 980 | $plugin->event($this, $event, $params); |
| 981 | 981 | } |
| 982 | 982 | } |
@@ -1117,7 +1117,7 @@ discard block |
||
| 1117 | 1117 | { |
| 1118 | 1118 | if ( ! method_exists($this, $method)) |
| 1119 | 1119 | { |
| 1120 | - if ( $this->typeExists($method)) { |
|
| 1120 | + if ($this->typeExists($method)) { |
|
| 1121 | 1121 | return $this->addField($method, array_shift($parameters)); |
| 1122 | 1122 | } |
| 1123 | 1123 | } |