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([
|
$resolver->setDefaults([
|
||||||
'view' => '@Core/admin/crud/field/boolean.html.twig',
|
'view' => '@Core/admin/crud/field/boolean.html.twig',
|
||||||
|
'display' => 'toggle',
|
||||||
'default_value' => false,
|
'default_value' => false,
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
$resolver->setAllowedTypes('display', 'string');
|
||||||
|
|
||||||
return $resolver;
|
return $resolver;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -694,3 +694,8 @@ form {
|
||||||
.tox.tox-silver-sink.tox-tinymce-aux {
|
.tox.tox-silver-sink.tox-tinymce-aux {
|
||||||
z-index: 3000 !important;
|
z-index: 3000 !important;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.field-boolean {
|
||||||
|
color: #49555b;
|
||||||
|
font-size: 20px;
|
||||||
|
}
|
||||||
|
|
|
@ -1,11 +1,26 @@
|
||||||
{%- block value -%}
|
{%- block value -%}
|
||||||
{% if value|default(options.default_value) %}
|
{% set value = value|default(options.default_value) %}
|
||||||
<span class="rounded-pill pl-3 pr-1 bg-secondary text-white">
|
<span class="field-boolean">
|
||||||
<span class="fa fa-circle"></span>
|
{% if options.display == 'checkbox' %}
|
||||||
</span>
|
{% block checkbox %}
|
||||||
{% else %}
|
{% if value %}
|
||||||
<span class="rounded-pill pr-3 pl-1 bg-secondary text-white">
|
<span class="fa fa-check-square"></span>
|
||||||
<span class="fa fa-circle"></span>
|
{% else %}
|
||||||
</span>
|
<span class="fa fa-square"></span>
|
||||||
{% endif %}
|
{% 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>
|
||||||
|
{% else %}
|
||||||
|
<span class="rounded-pill pr-3 pl-1 bg-secondary text-white">
|
||||||
|
<span class="fa fa-circle"></span>
|
||||||
|
</span>
|
||||||
|
{% endif %}
|
||||||
|
{% block %}
|
||||||
|
{% endif %}
|
||||||
|
</span>
|
||||||
{%- endblock -%}
|
{%- endblock -%}
|
||||||
|
|
Loading…
Reference in a new issue