add boolean field for CRUD
This commit is contained in:
parent
e2c9ecb941
commit
f144760085
24
src/core/Crud/Field/BooleanField.php
Normal file
24
src/core/Crud/Field/BooleanField.php
Normal file
|
@ -0,0 +1,24 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Core\Crud\Field;
|
||||||
|
|
||||||
|
use Symfony\Component\OptionsResolver\OptionsResolver;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* class BooleanField.
|
||||||
|
*
|
||||||
|
* @author Simon Vieille <simon@deblan.fr>
|
||||||
|
*/
|
||||||
|
class BooleanField extends Field
|
||||||
|
{
|
||||||
|
public function configureOptions(OptionsResolver $resolver): OptionsResolver
|
||||||
|
{
|
||||||
|
parent::configureOptions($resolver);
|
||||||
|
|
||||||
|
$resolver->setDefaults([
|
||||||
|
'view' => '@Core/admin/crud/field/boolean.html.twig',
|
||||||
|
]);
|
||||||
|
|
||||||
|
return $resolver;
|
||||||
|
}
|
||||||
|
}
|
11
src/core/Resources/views/admin/crud/field/boolean.html.twig
Normal file
11
src/core/Resources/views/admin/crud/field/boolean.html.twig
Normal file
|
@ -0,0 +1,11 @@
|
||||||
|
{%- block value -%}
|
||||||
|
{% 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 %}
|
||||||
|
{%- endblock -%}
|
Loading…
Reference in a new issue