@@ -347,7 +347,9 @@ discard block |
||
| 347 | 347 | return false; |
| 348 | 348 | } |
| 349 | 349 | |
| 350 | - if (isset($this->errors[$method])) unset($this->errors[$method]); |
|
| 350 | + if (isset($this->errors[$method])) { |
|
| 351 | + unset($this->errors[$method]); |
|
| 352 | + } |
|
| 351 | 353 | |
| 352 | 354 | return true; |
| 353 | 355 | } |
@@ -389,7 +391,9 @@ discard block |
||
| 389 | 391 | */ |
| 390 | 392 | public function error($message) |
| 391 | 393 | { |
| 392 | - if ( ! isset($this->errors['userDefined'])) $this->errors['userDefined'] = []; |
|
| 394 | + if ( ! isset($this->errors['userDefined'])) { |
|
| 395 | + $this->errors['userDefined'] = []; |
|
| 396 | + } |
|
| 393 | 397 | |
| 394 | 398 | $this->errors['userDefined'][] = $message; |
| 395 | 399 | } |
@@ -6,7 +6,7 @@ |
||
| 6 | 6 | |
| 7 | 7 | class Memory extends Plugin { |
| 8 | 8 | |
| 9 | - // Protects input from accidental loss |
|
| 9 | + // Protects input from accidental loss |
|
| 10 | 10 | // by saving as you type. WIP |
| 11 | 11 | |
| 12 | 12 | } |
| 13 | 13 | \ No newline at end of file |
@@ -6,40 +6,40 @@ |
||
| 6 | 6 | |
| 7 | 7 | class Feedback extends Plugin { |
| 8 | 8 | |
| 9 | - public function onLoad($form) |
|
| 10 | - { |
|
| 11 | - $form->addButton('feedback_trigger_'.$form->id); |
|
| 12 | - } |
|
| 9 | + public function onLoad($form) |
|
| 10 | + { |
|
| 11 | + $form->addButton('feedback_trigger_'.$form->id); |
|
| 12 | + } |
|
| 13 | 13 | |
| 14 | - public function onSubmitted($form) |
|
| 15 | - { |
|
| 16 | - $request = $form->getRequest(); |
|
| 14 | + public function onSubmitted($form) |
|
| 15 | + { |
|
| 16 | + $request = $form->getRequest(); |
|
| 17 | 17 | |
| 18 | - if ($request->get('feedback_trigger_'.$form->id)) { |
|
| 18 | + if ($request->get('feedback_trigger_'.$form->id)) { |
|
| 19 | 19 | |
| 20 | - $field = $form->field($request->get('name')); |
|
| 20 | + $field = $form->field($request->get('name')); |
|
| 21 | 21 | |
| 22 | - if ( ! is_null($field)) { |
|
| 22 | + if ( ! is_null($field)) { |
|
| 23 | 23 | |
| 24 | - $field->setFromRequest($request); |
|
| 25 | - $field->runValidations(); |
|
| 24 | + $field->setFromRequest($request); |
|
| 25 | + $field->runValidations(); |
|
| 26 | 26 | |
| 27 | - $response = [ |
|
| 28 | - 'id' => $field->id, |
|
| 29 | - 'valid' => $field->valid(), |
|
| 30 | - 'error_id' => 'feedback_errors_'.$field->id, |
|
| 31 | - 'error' => '', |
|
| 32 | - ]; |
|
| 27 | + $response = [ |
|
| 28 | + 'id' => $field->id, |
|
| 29 | + 'valid' => $field->valid(), |
|
| 30 | + 'error_id' => 'feedback_errors_'.$field->id, |
|
| 31 | + 'error' => '', |
|
| 32 | + ]; |
|
| 33 | 33 | |
| 34 | - if ( ! $field->valid()) { |
|
| 35 | - $response['error'] = $form->renderFieldErrors($field); |
|
| 36 | - } |
|
| 34 | + if ( ! $field->valid()) { |
|
| 35 | + $response['error'] = $form->renderFieldErrors($field); |
|
| 36 | + } |
|
| 37 | 37 | |
| 38 | - header('Content-Type: application/json'); |
|
| 39 | - echo json_encode($response); |
|
| 40 | - exit(); |
|
| 41 | - } |
|
| 42 | - } |
|
| 43 | - } |
|
| 38 | + header('Content-Type: application/json'); |
|
| 39 | + echo json_encode($response); |
|
| 40 | + exit(); |
|
| 41 | + } |
|
| 42 | + } |
|
| 43 | + } |
|
| 44 | 44 | |
| 45 | 45 | } |
| 46 | 46 | \ No newline at end of file |
@@ -1,7 +1,7 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | 3 | return [ |
| 4 | - 'plugins' => [ |
|
| 5 | - 'feedback', |
|
| 6 | - ], |
|
| 4 | + 'plugins' => [ |
|
| 5 | + 'feedback', |
|
| 6 | + ], |
|
| 7 | 7 | ]; |
| 8 | 8 | \ No newline at end of file |
@@ -1,7 +1,7 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | 3 | return [ |
| 4 | - 'validate_min' => 'El tamaño de [field] debe ser de al menos [min].', |
|
| 5 | - 'validate_max' => 'El campo [field] no debe ser mayor a [max].', |
|
| 6 | - 'validate_between' => 'El campo [field] tiene que estar entre [min] - [max].', |
|
| 4 | + 'validate_min' => 'El tamaño de [field] debe ser de al menos [min].', |
|
| 5 | + 'validate_max' => 'El campo [field] no debe ser mayor a [max].', |
|
| 6 | + 'validate_between' => 'El campo [field] tiene que estar entre [min] - [max].', |
|
| 7 | 7 | ]; |
| 8 | 8 | \ No newline at end of file |
@@ -1,7 +1,7 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | 3 | return [ |
| 4 | - 'validate_min' => 'The [field] field must be a minimum of [min].', |
|
| 5 | - 'validate_max' => 'The [field] field must be a maximum of [min].', |
|
| 6 | - 'validate_between' => 'The [field] field must be between [min] and [max].', |
|
| 4 | + 'validate_min' => 'The [field] field must be a minimum of [min].', |
|
| 5 | + 'validate_max' => 'The [field] field must be a maximum of [min].', |
|
| 6 | + 'validate_between' => 'The [field] field must be between [min] and [max].', |
|
| 7 | 7 | ]; |
| 8 | 8 | \ No newline at end of file |
@@ -32,12 +32,16 @@ discard block |
||
| 32 | 32 | |
| 33 | 33 | public function setValuesFromDefaults($defaults) |
| 34 | 34 | { |
| 35 | - if (count($this->defaults)) $this->value = array_shift($this->defaults); |
|
| 35 | + if (count($this->defaults)) { |
|
| 36 | + $this->value = array_shift($this->defaults); |
|
| 37 | + } |
|
| 36 | 38 | } |
| 37 | 39 | |
| 38 | 40 | public function setValuesFromModel($model) |
| 39 | 41 | { |
| 40 | - if (property_exists($model, $this->name)) $this->value = $model->{$this->name}; |
|
| 42 | + if (property_exists($model, $this->name)) { |
|
| 43 | + $this->value = $model->{$this->name}; |
|
| 44 | + } |
|
| 41 | 45 | } |
| 42 | 46 | |
| 43 | 47 | public function setValuesFromRequest($request) |
@@ -47,7 +51,9 @@ discard block |
||
| 47 | 51 | |
| 48 | 52 | public function fillModelWithValues($model) |
| 49 | 53 | { |
| 50 | - if (property_exists($model, $this->name)) $model->{$this->name} = $this->value; |
|
| 54 | + if (property_exists($model, $this->name)) { |
|
| 55 | + $model->{$this->name} = $this->value; |
|
| 56 | + } |
|
| 51 | 57 | } |
| 52 | 58 | |
| 53 | 59 | public function validate() |
@@ -1,6 +1,6 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | 3 | return [ |
| 4 | - 'placeholder_first' => 'Nombre', |
|
| 5 | - 'placeholder_surname' => 'Apellido', |
|
| 4 | + 'placeholder_first' => 'Nombre', |
|
| 5 | + 'placeholder_surname' => 'Apellido', |
|
| 6 | 6 | ]; |
| 7 | 7 | \ No newline at end of file |
@@ -1,6 +1,6 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | 3 | return [ |
| 4 | - 'placeholder_first' => 'First', |
|
| 5 | - 'placeholder_surname' => 'Surname', |
|
| 4 | + 'placeholder_first' => 'First', |
|
| 5 | + 'placeholder_surname' => 'Surname', |
|
| 6 | 6 | ]; |
| 7 | 7 | \ No newline at end of file |