diff --git a/protected/src/controllers/app/home_ctrl.php b/protected/src/controllers/app/home_ctrl.php
index cc4c20f..232ae3c 100644
--- a/protected/src/controllers/app/home_ctrl.php
+++ b/protected/src/controllers/app/home_ctrl.php
@@ -11,6 +11,7 @@ namespace Project\controllers\app;
use \CodeHydrater\base_controller;
use \CodeHydrater\enums\view_type as ViewType;
+use \CodeHydrater\bootstrap\use_iol as IOL;
/**
* Description of home_ctrl URL Route: /FOLDER/FILE/METHOD
@@ -57,15 +58,7 @@ class home_ctrl extends base_controller {
}
public function val_tests() {
- $user_test = new \Project\inputs\test_val("Joe", 10, "Joe@AOL.com");
-
- $v = new \CodeHydrater\attributes\validators\my_validator();
- $v->validate($user_test);
-
- $errors = $v->get_errors();
- print_r($errors);
-
- $this->response->set_content("Done");
+ IOL::auto_wire($this, "app", "home", "val_tests", null);
return $this->response;
}
diff --git a/protected/src/inputs/app/home_in.php b/protected/src/inputs/app/home_in.php
new file mode 100644
index 0000000..08c0575
--- /dev/null
+++ b/protected/src/inputs/app/home_in.php
@@ -0,0 +1,86 @@
+
+ * @copyright (c) 2025, Robert Strutts
+ * @license MIT
+ */
+
+namespace Project\inputs\app;
+
+use \CodeHydrater\attributes\validators as Assert;
+use \CodeHydrater\enums\INPUTS;
+use \CodeHydrater\enums\FIELD_FILTER;
+use \CodeHydrater\enums\HTML_FLAG;
+use \CodeHydrater\enums\DB_FILTER;
+use \CodeHydrater\bootstrap\use_io as IO;
+use \CodeHydrater\bootstrap\safer_io as SafeIO;
+
+class home_in {
+
+ private static function define_io(string $v_rule = 'required|max: 70') {
+ $required_post_string_field = new IO();
+ $required_post_string_field->input_type = INPUTS::variable;
+ $required_post_string_field->field_filter = FIELD_FILTER::raw_string;
+ $required_post_string_field->escape_html = HTML_FLAG::escape;
+ $required_post_string_field->validation_rule = $v_rule;
+ $required_post_string_field->use_db_filter = DB_FILTER::OFF;
+ $required_post_string_field->skip_the_db = false;
+ return $required_post_string_field;
+ }
+
+ public static function val_tests(object $app): array {
+ $posts_data = $app->request->get_post_data();
+
+ $user_test_data = new my_val_tests_form(
+ $posts_data->get("name"),
+ intval($posts_data->get("age")),
+ $posts_data->get("email")
+ );
+
+ unset($posts_data); // free it up...
+
+ SafeIO::set_data_input('name', $user_test_data->name);
+ SafeIO::set_data_input('age', $user_test_data->age);
+ SafeIO::set_data_input('email', $user_test_data->email);
+
+ $v = new \CodeHydrater\attributes\validators\my_validator();
+ $v->validate($user_test_data);
+
+ $name_field = self::define_io();
+
+ $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_message = ['greater_than' => 'The %s must be an Adult over %d!'];
+
+ $email_field = self::define_io('required|max: 255');
+
+ return [
+ 'html' => [
+ 'name' => $name_field,
+ 'age' => $adult_post_int_age_field,
+ 'email' => $email_field,
+ ],
+ 'post_data' => get_object_vars($user_test_data),
+ 'a_errors' => $v->get_errors()
+ ];
+ }
+}
+
+class my_val_tests_form {
+ public function __construct(
+ #[Assert\Required]
+ #[Assert\Max(70)]
+ public ?string $name = null,
+ #[Assert\Positive]
+ #[Assert\NumberRange(18, 130)]
+ public ?int $age = null,
+ #[Assert\Between(2, 255)]
+ #[Assert\Email]
+ public ?string $email = null
+ ) {}
+}
\ No newline at end of file
diff --git a/protected/src/inputs/test_val.php b/protected/src/inputs/test_val.php
deleted file mode 100644
index 8f4351c..0000000
--- a/protected/src/inputs/test_val.php
+++ /dev/null
@@ -1,29 +0,0 @@
-
- * @copyright (c) 2025, Robert Strutts
- * @license MIT
- */
-
-namespace Project\inputs;
-
-use \CodeHydrater\attributes\validators as Assert;
-
-class test_val {
- public function __construct(
- #[Assert\Required]
- #[Assert\Max(70)]
- public ?string $name = null,
- #[Assert\Positive]
- #[Assert\NumberRange(18, 65)]
- public ?int $age = null,
- #[Assert\Between(2, 255)]
- #[Assert\Email]
- public ?string $email = null
- ) {
- echo $this->name;
- }
-}
\ No newline at end of file
diff --git a/protected/src/outputs/app/home_out.php b/protected/src/outputs/app/home_out.php
new file mode 100644
index 0000000..17a2742
--- /dev/null
+++ b/protected/src/outputs/app/home_out.php
@@ -0,0 +1,69 @@
+
+ * @copyright (c) 2025, Robert Strutts
+ * @license MIT
+ */
+
+namespace Project\outputs\app;
+
+use CodeHydrater\bootstrap\safer_io as SafeIO;
+use \CodeHydrater\enums\view_type as ViewType;
+
+class home_out {
+ public static function val_tests(object $app, array & $input): array {
+ $html_output = [];
+ $errors = [];
+ foreach(SafeIO::html_escape_and_sanitize($input['html']) as $html) {
+ $key = $html['name'] ?? "";
+ $html_output[$key] = $html['html'];
+
+ if (\CodeHydrater\common::get_count($html['errors'])) {
+ $errors[$key] = $html['errors'][$key];
+ }
+ }
+
+ $data = [
+ 'safe_html' => $html_output,
+ 'post_data' =>$input['post_data'],
+ 'a_errors' => array_merge($input['a_errors'], $errors),
+ ];
+
+ $app->view->set('twig_data', [
+ ...$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',
+ ]);
+ $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/default/app/home_index.php b/protected/src/views/default/app/home_index.php
index bd28722..13fd28b 100644
--- a/protected/src/views/default/app/home_index.php
+++ b/protected/src/views/default/app/home_index.php
@@ -8,6 +8,9 @@ $method_name_demo = "twig";
$route_liquid = "app/home";
$method_liquid = "liquid";
+$route_form = "app/home";
+$method_form = "val_tests";
+
$route_rss = "app/rss";
$method_rss = "feed.xml";
@@ -25,6 +28,11 @@ $method_rss = "feed.xml";
||
+
+HTML Form Filter Demo
+
+||
+
View RSS XML feed Demo
\ 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
new file mode 100644
index 0000000..0d1fa8d
--- /dev/null
+++ b/protected/src/views/twig/app/val_tests.html.twig
@@ -0,0 +1,41 @@
+
+
+