|
- <?php
-
- namespace Lc\SovBundle\Field;
-
- use EasyCorp\Bundle\EasyAdminBundle\Contracts\Field\FieldInterface;
- use EasyCorp\Bundle\EasyAdminBundle\Field\FieldTrait;
- use Lc\SovBundle\Field\Filter\BooleanFilter;
- use Lc\SovBundle\Field\Filter\CheckboxFilter;
- use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
-
- /**
- * @author La clic ! <contact@laclic.fr>
- */
- final class StatusField implements FieldInterface
- {
- use FieldTrait;
-
- public static function new(string $propertyName, ?string $label = null, bool $templateToggle = true): self
- {
- $field = (new self())
- ->setProperty($propertyName)
- ->setLabel($label)
- ->setFormType(ChoiceType::class)
- ->setFormTypeOption('expanded', true)
- ->setFormTypeOption('multiple', false)
- ->setFormTypeOption('choices', ['En ligne' => 1, 'Hors ligne' => 0])
- ->setFormTypeOption('placeholder', false)
- ->setCustomOption('toggle_label', 'En ligne')
- ->setCustomOption('filter_fqcn', CheckboxFilter::class);
-
- $template = 'toggle.html.twig';
- if (!$templateToggle) {
- $template = 'status.html.twig';
- }
- $field->setTemplatePath('@LcSov/adminlte/crud/field/' . $template);
-
- return $field;
- }
-
- }
|