Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

StatusField.php 1.3KB

pirms 3 gadiem
123456789101112131415161718192021222324252627282930313233343536373839
  1. <?php
  2. namespace Lc\SovBundle\Field;
  3. use EasyCorp\Bundle\EasyAdminBundle\Contracts\Field\FieldInterface;
  4. use EasyCorp\Bundle\EasyAdminBundle\Field\FieldTrait;
  5. use Lc\SovBundle\Form\Type\FileManagerType;
  6. use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
  7. use Symfony\Component\Form\Extension\Core\Type\TextType;
  8. /**
  9. * @author La clic ! <contact@laclic.fr>
  10. */
  11. final class StatusField implements FieldInterface
  12. {
  13. use FieldTrait;
  14. public static function new(string $propertyName, ?string $label = null, bool $templateToggle = true): self
  15. {
  16. $field = (new self())
  17. ->setProperty($propertyName)
  18. ->setLabel($label)
  19. ->setFormType(ChoiceType::class)
  20. ->setFormTypeOption('expanded', true)
  21. ->setFormTypeOption('multiple', false)
  22. ->setFormTypeOption('choices', ['En ligne' => 1, 'Hors ligne' => 0])
  23. ->setCustomOption('toggle_label', 'En ligne');
  24. $template = 'toggle.html.twig' ;
  25. if(!$templateToggle) {
  26. $template = 'status.html.twig' ;
  27. }
  28. $field->setTemplatePath('@LcSov/adminlte/crud/field/'.$template) ;
  29. return $field ;
  30. }
  31. }