From adc34b6c1a2f46f28002e001045fe747709e9050 Mon Sep 17 00:00:00 2001 From: Eddiedigits Date: Mon, 4 Nov 2024 07:16:52 +0100 Subject: [PATCH] Form style bootstrap5 (#939) * added FormStyleBootstrap5 to form.py * Revert "added FormStyleBootstrap5 to form.py" This reverts commit f9c0af94955fad01529daa2898f6a7114dbfc33a. * added FormStyleBootstrap5 to form.py --- py4web/utils/form.py | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/py4web/utils/form.py b/py4web/utils/form.py index 483360c7..992382d2 100644 --- a/py4web/utils/form.py +++ b/py4web/utils/form.py @@ -651,6 +651,30 @@ def __call__( } ) +FormStyleBootstrap5 = FormStyleFactory() +FormStyleBootstrap5.classes.update( + { + "outer": "mb-3 col-auto", # Replaced 'form-group' with 'mb-3' for margin-bottom + "inner": "", + "label": "form-label", # Explicitly use 'form-label' for labels + "info": "form-text", + "error": "form-text text-danger py4web-validation-error", + "submit": "btn btn-primary", + "input": "form-control", + "input[type=text]": "form-control", + "input[type=date]": "form-control", + "input[type=time]": "form-control", + "input[type=datetime-local]": "form-control", + "input[type=radio]": "form-check-input", + "input[type=checkbox]": "form-check-input", + "input[type=submit]": "btn btn-primary", + "input[type=password]": "form-control", + "input[type=file]": "form-control", # Bootstrap 5 doesn't have a specific 'form-control-file' class + "select": "form-select", # 'form-select' is used in Bootstrap 5 instead of 'form-control' for select elements + "textarea": "form-control", + } +) + # ################################################################ # Form object (replaced SQLFORM) # ################################################################