Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Style button groups in forms #268

Merged
merged 2 commits into from
Mar 2, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions assets/css/app.css
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
1 change: 1 addition & 0 deletions config/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ monolog:
formatter: 'monolog.formatter.json'

twig:
form_themes: ['tabler_form_layout.html.twig']
strict_variables: '%kernel.debug%'

services:
Expand Down
24 changes: 24 additions & 0 deletions templates/tabler_form_layout.html.twig
Original file line number Diff line number Diff line change
@@ -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 %}
<legend class="form-label{{ required ? ' required' }}">{{ label }}</legend>
{% 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 -%}
<div {{ block('widget_container_attributes') }}>
{%- for child in form %}
{{- form_widget(child, {
required: false,
parent_label_class: label_attr.class|default(''),
translation_domain: choice_translation_domain,
valid: valid,
}) -}}
{% endfor -%}
</div>
{%- endblock choice_widget_expanded %}
8 changes: 8 additions & 0 deletions tests/_support/AcceptanceTester.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
use Codeception\Actor;
use Codeception\Lib\Actor\Shared\Friend;
use Codeception\Lib\Actor\Shared\Retry;
use Codeception\Scenario;

/**
* Inherited Methods
Expand All @@ -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);
}
}