build_group

main
Robert 1 month ago
parent 38734121de
commit 4ca5b8662d
  1. 5
      protected/src/configs/on_footer_banner.php
  2. 27
      protected/src/inputs/app/home/val_tests_in.php
  3. 20
      protected/src/outputs/app/home/val_tests_out.php

@ -10,11 +10,10 @@ declare(strict_types=1);
namespace Project;
class MyPage {
public const string MyFooter = '<footer style="
public const string MyFooter = '<br><br><br><footer style="
background-color: #333;
color: white;
text-align: center;
padding: 5px 0;
position: fixed;
bottom: 0;
width: 100%;
@ -23,7 +22,7 @@ class MyPage {
">
<div style="max-width: 800px; margin: 0 auto;">
<p style="margin: 0; padding: 0;">&copy; <?= date("Y") ?> Your Company Name. All rights reserved.</p>
<p style="margin: 10px 0 0 0; padding: 0; font-size: 0.8em;">
<p style="margin: 2px 0 0 0; padding: 0; font-size: 0.8em;">
<a href="/privacy" style="color: #4da6ff; text-decoration: none;">Privacy Policy</a> |
<a href="/terms" style="color: #4da6ff; text-decoration: none;">Terms of Service</a> |
<a href="/contact" style="color: #4da6ff; text-decoration: none;">Contact Us</a>

@ -34,7 +34,7 @@ class val_tests_in {
public static function entry(object $app): array {
$html['name'] = self::define_io("Full Name");
$html['personality'] = self::define_io("Personality Type");
$html['personality'] = self::define_io("Personality Type", "");
$html['personality']->form_data_list = ["cool"=>"Cool", "smart"=>"Smart", "fun"=>"Fun"];
$html['personality']->form_type = FORM_TYPE::select;
$html['personality']->form_control_class = "select";
@ -48,14 +48,33 @@ class val_tests_in {
$html['age']->validation_message = ['number_range' => 'The %s must be an Adult over %d and under %d!'];
$html['email'] = self::define_io("Email Address", 'required|between: 7, 255|email');
$html['email']->form_type = FORM_TYPE::email;
$html['agree'] = self::define_io("I Agree to the Terms");
$html['agree']->form_type = FORM_TYPE::checkbox;
$html['agree']->form_check_or_radio_value = "IAgree";
$html['agree']->form_control_class = "checkbox";
$html['dogs'] = self::define_io("I like dogs", "");
$html['dogs']->form_type = FORM_TYPE::radio;
$html['dogs']->form_check_or_radio_name = "pets";
$html['dogs']->form_check_or_radio_value = "Dog";
$html['dogs']->form_control_class = "radio";
$html['cats'] = self::define_io("I like cats", "");
$html['cats']->form_type = FORM_TYPE::radio;
$html['cats']->form_check_or_radio_name = "pets";
$html['cats']->form_check_or_radio_value = "Cat";
$html['cats']->form_control_class = "radio";
return [
'method' => $app->request->get_method(),
'html' => $html,
'classes' => [
'div-class' => 'mb-3',
'form-control-class' => 'form-control',
'label-class' => '',
'div_class' => 'mb-3',
'form_control_class' => 'form-control',
'label_class' => 'form-label',
],
];
}

@ -15,35 +15,37 @@ use \CodeHydrater\enums\view_type as ViewType;
use \CodeHydrater\form_builder\html_form as Form;
class val_tests_out {
private static function build_form(array $a): ?string {
private static function build_form(array $input): array {
$div_class = $input['classes']['div_class'] ?? "";
$form_builder = new Form();
$form_builder->set_escape(false);
$form_builder->open(options: ['autocomplete'=>'off']);
$form_builder->fieldset_open(['style'=>'width: 200px;']);
$form_builder->legend("News Letter");
$form_builder->build_group($a);
$form_builder->open_div(['class'=>$a['div-class']]);
$data = $form_builder->build_group($input);
$form_builder->open_div(['class'=>$div_class]);
$form_builder->submit("go", ['class'=>'btn btn-primary']);
$form_builder->close_div();
$form_builder->fieldset_close();
$form_builder->close();
return $form_builder->get_output();
$out = $form_builder->get_output();
return ['out'=>$out, 'errors'=>$data['errors'], 'html_output'=>$data['html_output'], 'headers'=>$data['headers']];
}
public static function entry(object $app, array $input): array {
$a = SafeIO::build_html($input);
$build = self::build_form($input);
$did_submit = ($input['method'] === "POST");
// $name = $app->request->get_post_data()->get("name") ?? "Annon.";
$twig_data = [
'form_builder' => self::build_form($a),
'form_builder' => $build['out'],
'table_options' => ['helper' => 'single-row','escape' => false],
'safe_html' => $a['html'],
'safe_html' => $build['html_output'],
'did_submit' => $did_submit,
'table_headers' => $a['headers'],
'table_headers' => $build['headers'],
// 'safe_name' => \CodeHydrater\bootstrap\safer_io::h($name),
'a_errors' => $a['errors'],
'a_errors' => $build['errors'],
];
$app->view->set('twig_data', $twig_data);

Loading…
Cancel
Save