From ad86a4469d09b04ef0f1fdd0e79037cfab092dd1 Mon Sep 17 00:00:00 2001 From: Markus Reinhold Date: Sun, 2 Mar 2025 16:43:23 +0100 Subject: [PATCH] Style button groups in forms (#268) Additionally, set default retry to 3 in acceptance tests. --- assets/css/app.css | 8 ++++++++ config/config.yml | 1 + templates/tabler_form_layout.html.twig | 24 ++++++++++++++++++++++++ tests/_support/AcceptanceTester.php | 8 ++++++++ 4 files changed, 41 insertions(+) create mode 100644 templates/tabler_form_layout.html.twig diff --git a/assets/css/app.css b/assets/css/app.css index 63f4304a..7e0672bc 100644 --- a/assets/css/app.css +++ b/assets/css/app.css @@ -179,3 +179,11 @@ notification-list { [data-bs-theme=dark] .gp-game__field { border-color: var(--tblr-blue); } + +/** Fix specificity for checked buttons on hover */ +.btn-check:checked + .btn:hover { + color: var(--tblr-btn-active-color); + background-color: var(--tblr-btn-active-bg); + border-color: var(--tblr-btn-active-border-color); + box-shadow: var(--tblr-btn-active-shadow) +} diff --git a/config/config.yml b/config/config.yml index 9bb70c85..9ea29136 100644 --- a/config/config.yml +++ b/config/config.yml @@ -25,6 +25,7 @@ monolog: formatter: 'monolog.formatter.json' twig: + form_themes: ['tabler_form_layout.html.twig'] strict_variables: '%kernel.debug%' services: diff --git a/templates/tabler_form_layout.html.twig b/templates/tabler_form_layout.html.twig new file mode 100644 index 00000000..fec7d133 --- /dev/null +++ b/templates/tabler_form_layout.html.twig @@ -0,0 +1,24 @@ +{% use "bootstrap_5_layout.html.twig" %} + +{# Override to ignore label_attr for expanded choices, allowing them to be rendered as buttons. #} +{%- block choice_label -%} + {% if expanded is defined and expanded %} + {{ label }} + {% else %} + {{- parent() -}} + {% endif %} +{%- endblock choice_label %} + +{# Override to ensure choices don't inherit the required attribute, removing the asterisk from each choice. #} +{%- block choice_widget_expanded -%} +
+ {%- for child in form %} + {{- form_widget(child, { + required: false, + parent_label_class: label_attr.class|default(''), + translation_domain: choice_translation_domain, + valid: valid, + }) -}} + {% endfor -%} +
+{%- endblock choice_widget_expanded %} diff --git a/tests/_support/AcceptanceTester.php b/tests/_support/AcceptanceTester.php index a717f433..40b05b4f 100644 --- a/tests/_support/AcceptanceTester.php +++ b/tests/_support/AcceptanceTester.php @@ -5,6 +5,7 @@ use Codeception\Actor; use Codeception\Lib\Actor\Shared\Friend; use Codeception\Lib\Actor\Shared\Retry; +use Codeception\Scenario; /** * Inherited Methods @@ -26,4 +27,11 @@ class AcceptanceTester extends Actor use _generated\AcceptanceTesterActions; use Friend; use Retry; + + public function __construct(Scenario $scenario) + { + parent::__construct($scenario); + + $this->retry(3); + } }