add the option 'display' on BooleanField
add displays toggle and checkbox for BooleanField
This commit is contained in:
parent
bd4338bb2d
commit
200dd0b8d6
|
@ -17,9 +17,12 @@ class BooleanField extends Field
|
|||
|
||||
$resolver->setDefaults([
|
||||
'view' => '@Core/admin/crud/field/boolean.html.twig',
|
||||
'display' => 'toggle',
|
||||
'default_value' => false,
|
||||
]);
|
||||
|
||||
$resolver->setAllowedTypes('display', 'string');
|
||||
|
||||
return $resolver;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -694,3 +694,8 @@ form {
|
|||
.tox.tox-silver-sink.tox-tinymce-aux {
|
||||
z-index: 3000 !important;
|
||||
}
|
||||
|
||||
.field-boolean {
|
||||
color: #49555b;
|
||||
font-size: 20px;
|
||||
}
|
||||
|
|
|
@ -1,5 +1,17 @@
|
|||
{%- block value -%}
|
||||
{% if value|default(options.default_value) %}
|
||||
{% set value = value|default(options.default_value) %}
|
||||
<span class="field-boolean">
|
||||
{% if options.display == 'checkbox' %}
|
||||
{% block checkbox %}
|
||||
{% if value %}
|
||||
<span class="fa fa-check-square"></span>
|
||||
{% else %}
|
||||
<span class="fa fa-square"></span>
|
||||
{% endif %}
|
||||
{% endblock %}
|
||||
{% elseif options.display == 'toggle' %}
|
||||
{% block toggle %}
|
||||
{% if value %}
|
||||
<span class="rounded-pill pl-3 pr-1 bg-secondary text-white">
|
||||
<span class="fa fa-circle"></span>
|
||||
</span>
|
||||
|
@ -8,4 +20,7 @@
|
|||
<span class="fa fa-circle"></span>
|
||||
</span>
|
||||
{% endif %}
|
||||
{% block %}
|
||||
{% endif %}
|
||||
</span>
|
||||
{%- endblock -%}
|
||||
|
|
Loading…
Reference in a new issue