wip: replace flatpickr
This commit is contained in:
1 parent
675e583057
commit
d356725ff5
5 files changed
+80
-58
No files matched your search
@@ -162,21 +162,31 @@
|
||||
{%- block datepicker_widget -%}
|
||||
{%- set minDate = form.vars.min_date ? form.vars.min_date | date('Y-m-d') : null -%}
|
||||
{%- set maxDate = form.vars.max_date ? form.vars.max_date | date('Y-m-d') : null -%}
|
||||
{%- set attr = attr|merge({'class': (attr.class|default('') ~ ' block w-full rounded-md border-0 py-1.5 text-gray-900 shadow-sm ring-1 ring-inset ring-gray-300 focus:ring-2 focus:ring-inset text-sm')|trim }) -%}
|
||||
{%- set displayValue = value ? value|date('d.m.Y') : '' -%}
|
||||
{%- set inputClass = 'block w-full rounded-md border-0 py-1.5 text-gray-900 shadow-sm ring-1 ring-inset ring-gray-300 focus:ring-2 focus:ring-inset text-sm' -%}
|
||||
{%- if errors|length -%}
|
||||
{%- set attr = attr|merge({'class': attr.class|default('') ~ ' ring-red-500 placeholder:red-500 focus:ring-red-500' }) -%}
|
||||
{% else %}
|
||||
{%- set attr = attr|merge({'class': attr.class|default('') ~ ' placeholder:text-gray-900 focus:ring-primary' }) -%}
|
||||
{%- set inputClass = inputClass ~ ' ring-red-500 placeholder:red-500 focus:ring-red-500' -%}
|
||||
{%- else -%}
|
||||
{%- set inputClass = inputClass ~ ' placeholder:text-gray-900 focus:ring-primary' -%}
|
||||
{%- endif -%}
|
||||
{%- if disabled is defined and disabled == true -%}
|
||||
{%- set attr = attr|merge({'class': attr.class|default('') ~ ' cursor-not-allowed' }) -%}
|
||||
{%- set inputClass = inputClass ~ ' cursor-not-allowed' -%}
|
||||
{%- endif -%}
|
||||
<div {{ stimulus_controller('datepicker', { 'minDate': minDate, 'maxDate': maxDate, 'disableWeekends': form.vars.disable_weekends }) }}>
|
||||
<input type="text" name="{{ form.vars.full_name }}" value="{{ value }}" {{ block('widget_attributes') }} {{ stimulus_target('datepicker', 'field') }} />
|
||||
<input type="text"
|
||||
id="{{ id }}"
|
||||
class="{{ inputClass }}"
|
||||
value="{{ displayValue }}"
|
||||
{% if attr.placeholder is defined %}placeholder="{{ attr.placeholder }}"{% endif %}
|
||||
{% if attr['aria-describedby'] is defined %}aria-describedby="{{ attr['aria-describedby'] }}"{% endif %}
|
||||
{% if required %}required{% endif %}
|
||||
{% if disabled is defined and disabled %}disabled{% endif %}
|
||||
{{ stimulus_target('datepicker', 'field') }} />
|
||||
<input type="hidden"
|
||||
name="{{ form.vars.full_name }}"
|
||||
value="{{ value }}"
|
||||
{{ stimulus_target('datepicker', 'hiddenField') }} />
|
||||
</div>
|
||||
{%- if disabled is defined and disabled == true -%}
|
||||
<input type="hidden" name="{{ form.vars.full_name }}" value="{{ value }}">
|
||||
{%- endif -%}
|
||||
{%- endblock datepicker_widget %}
|
||||
|
||||
{%- block autocomplete_widget -%}
|
||||
|
||||
Reference in new issue
Block a user