您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

ToggleField.php 738B

12345678910111213141516171819202122232425
  1. <?php
  2. namespace Lc\SovBundle\Field;
  3. use EasyCorp\Bundle\EasyAdminBundle\Contracts\Field\FieldInterface;
  4. use EasyCorp\Bundle\EasyAdminBundle\Field\FieldTrait;
  5. use Symfony\Component\Form\Extension\Core\Type\CheckboxType;
  6. /**
  7. * @author La clic ! <contact@laclic.fr>
  8. */
  9. final class ToggleField implements FieldInterface
  10. {
  11. use FieldTrait;
  12. public static function new(string $propertyName, ?string $label = null): self
  13. {
  14. return (new self())
  15. ->setProperty($propertyName)
  16. ->setLabel($label)
  17. ->setTemplatePath('@LcSov/adminlte/crud/field/toggle.html.twig')
  18. ->setFormType(CheckboxType::class);
  19. }
  20. }