feat: improved tooltip and readonly handling of checkboxes
This commit is contained in:
@@ -65,18 +65,13 @@
|
|||||||
{%- endblock textarea_widget -%}
|
{%- endblock textarea_widget -%}
|
||||||
|
|
||||||
{%- block checkbox_widget -%}
|
{%- block checkbox_widget -%}
|
||||||
|
{%- set attr = attr|filter((v, k) => k != 'tooltip') -%}
|
||||||
{%- set attr = attr|merge({'class': (attr.class|default('') ~ ' form-checkbox')|trim }) -%}
|
{%- set attr = attr|merge({'class': (attr.class|default('') ~ ' form-checkbox')|trim }) -%}
|
||||||
{%- if errors|length -%}
|
{%- if errors|length -%}
|
||||||
{%- set attr = attr|merge({'class': attr.class|default('') ~ ' form-checkbox--has-error' }) -%}
|
{%- set attr = attr|merge({'class': attr.class|default('') ~ ' form-checkbox--has-error' }) -%}
|
||||||
{%- endif -%}
|
{%- endif -%}
|
||||||
{%- set tooltip = null -%}
|
{%- set tooltip = null -%}
|
||||||
{%- if attr.tooltip is defined -%}
|
<input type="checkbox" {{ block('widget_attributes') }}{% if value is defined %} value="{{ value }}"{% endif %}{% if checked %} checked="checked"{% endif %} />
|
||||||
{%- set tooltip = attr.tooltip -%}
|
|
||||||
{%- set attr = attr|filter((v, k) => k != 'tooltip') -%}
|
|
||||||
{%- endif -%}
|
|
||||||
<div{% if tooltip is not null %} {{ stimulus_controller('tooltip', { 'content': tooltip }) }}{% endif %}>
|
|
||||||
<input type="checkbox" {{ block('widget_attributes') }}{% if value is defined %} value="{{ value }}"{% endif %}{% if checked %} checked="checked"{% endif %} />
|
|
||||||
</div>
|
|
||||||
{%- endblock checkbox_widget -%}
|
{%- endblock checkbox_widget -%}
|
||||||
|
|
||||||
{%- block radio_widget -%}
|
{%- block radio_widget -%}
|
||||||
@@ -95,13 +90,17 @@
|
|||||||
{%- endblock radio_widget -%}
|
{%- endblock radio_widget -%}
|
||||||
|
|
||||||
{% block checkbox_row %}
|
{% block checkbox_row %}
|
||||||
<div class="{{ html_classes('relative flex items-start', { 'cursor-not-allowed': form.vars.attr.readonly is defined }) }}">
|
{%- set tooltip = null -%}
|
||||||
|
{%- if form.vars.attr.tooltip is defined -%}
|
||||||
|
{%- set tooltip = form.vars.attr.tooltip -%}
|
||||||
|
{%- endif -%}
|
||||||
|
<div class="{{ html_classes('relative flex items-start', { 'cursor-not-allowed': form.vars.attr.readonly is defined }) }}"{% if tooltip is not null %} {{ stimulus_controller('tooltip', { 'content': tooltip }) }}{% endif %}>
|
||||||
<div class="flex h-6 items-center">
|
<div class="flex h-6 items-center">
|
||||||
{{ form_widget(form) }}
|
{{ form_widget(form) }}
|
||||||
</div>
|
</div>
|
||||||
<div class="{{ html_classes('ml-1 leading-6', { 'text-red-500': errors|length }) }}">
|
<div class="{{ html_classes('ml-1 leading-6', { 'text-red-500': errors|length }) }}">
|
||||||
<label for="{{ form.vars.id }}">
|
<label for="{{ form.vars.id }}" class="{{ html_classes({ 'pointer-events-none': form.vars.attr.readonly is defined }) }}">
|
||||||
{{ form.vars.label }}
|
{{ form.vars.label | raw }}
|
||||||
</label>
|
</label>
|
||||||
{{- form_errors(form) -}}
|
{{- form_errors(form) -}}
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
Reference in New Issue
Block a user