diff --git a/protected/src/inputs/app/home_in.php b/protected/src/inputs/app/home_in.php
index 08c0575..0fe83cb 100644
--- a/protected/src/inputs/app/home_in.php
+++ b/protected/src/inputs/app/home_in.php
@@ -34,9 +34,12 @@ class home_in {
public static function val_tests(object $app): array {
$posts_data = $app->request->get_post_data();
+ $i_age = intval($posts_data->get("age"));
+ $age = ($i_age > 0) ? $i_age : null;
+
$user_test_data = new my_val_tests_form(
$posts_data->get("name"),
- intval($posts_data->get("age")),
+ $age,
$posts_data->get("email")
);
@@ -54,12 +57,14 @@ class home_in {
$adult_post_int_age_field = new IO();
$adult_post_int_age_field->input_type = INPUTS::post;
$adult_post_int_age_field->field_filter = FIELD_FILTER::integer_number;
- $adult_post_int_age_field->validation_rule = 'greater_than: 18';
+ $adult_post_int_age_field->validation_rule = 'greater_than: 17';
$adult_post_int_age_field->validation_message = ['greater_than' => 'The %s must be an Adult over %d!'];
$email_field = self::define_io('required|max: 255');
return [
+ 'method' => $app->request->get_method(),
+ 'headers' => ['Full Name', 'Age', 'Email'],
'html' => [
'name' => $name_field,
'age' => $adult_post_int_age_field,
diff --git a/protected/src/outputs/app/home_out.php b/protected/src/outputs/app/home_out.php
index 17a2742..e76384f 100644
--- a/protected/src/outputs/app/home_out.php
+++ b/protected/src/outputs/app/home_out.php
@@ -26,9 +26,15 @@ class home_out {
}
}
+ $one_row[] = $html_output;
+ $did_submit = ($input['method'] === "POST");
+
$data = [
+ 'did_submit' => $did_submit,
+ 'headers' => $input['headers'],
+ 'user' => $one_row,
'safe_html' => $html_output,
- 'post_data' =>$input['post_data'],
+ 'post_data' => $input['post_data'],
'a_errors' => array_merge($input['a_errors'], $errors),
];
@@ -36,34 +42,11 @@ class home_out {
...$data
]);
$app->view->set('twig_functions', [
- 'show_user_details' => '\Project\outputs\app\home_out::show_user_details',
- 'show_errors' => '\Project\outputs\app\home_out::show_errors',
+ 'show_table' => '\CodeHydrater\html::show_table',
+ 'show_errors' => '\CodeHydrater\html::show_errors',
]);
$content = $app->view->fetch($app, "app/val_tests.html", ViewType::TWIG);
$app->response->set_content($content);
return [];
}
-
-
- public static function show_errors(?array $errors = []): void {
- if ($errors) {
- $message = "Please correct the following errors: ";
- $i = 0;
- foreach($errors as $error) {
- $i++;
- $message .= "
{$i}) " . $error;
- }
- echo $message;
- }
- }
-
- public static function show_user_details(array $input): void {
- $rows[] = $input; // Force one rows
-
- \CodeHydrater\html::show_table(
- ['Full Name', 'Age', 'Email'],
- $rows,
- escape: false
- );
- }
}
\ No newline at end of file
diff --git a/protected/src/views/twig/app/val_tests.html.twig b/protected/src/views/twig/app/val_tests.html.twig
index 0d1fa8d..6114a02 100644
--- a/protected/src/views/twig/app/val_tests.html.twig
+++ b/protected/src/views/twig/app/val_tests.html.twig
@@ -5,28 +5,34 @@
{{ safe_html.name }}, you Rock!
- {% if a_errors %} -