Symfony ux:icons - Added Icons.

This commit is contained in:
2025-06-05 21:07:14 +02:00
parent 280179ca7e
commit 2e3a9031c9
15 changed files with 191 additions and 10 deletions
@@ -2,6 +2,7 @@
namespace App\Controller\Admin;
use App\Controller\Admin\Field\IconField;
use App\Entity\BedType;
use EasyCorp\Bundle\EasyAdminBundle\Controller\AbstractCrudController;
use EasyCorp\Bundle\EasyAdminBundle\Field\TextField;
@@ -17,6 +18,6 @@ class BedTypeCrudController extends AbstractCrudController
public function configureFields(string $pageName): iterable
{
yield TextField::new('name');
yield UrlField::new('iconUrl');
yield IconField::new('iconUrl');
}
}
+36
View File
@@ -0,0 +1,36 @@
<?php
namespace App\Controller\Admin\Field;
use EasyCorp\Bundle\EasyAdminBundle\Contracts\Field\FieldInterface;
use EasyCorp\Bundle\EasyAdminBundle\Field\FieldTrait;
use Symfony\Component\Form\Extension\Core\Type\TextType;
final class IconField implements FieldInterface
{
use FieldTrait;
/**
* @param TranslatableInterface|string|false|null $label
*/
public static function new(string $propertyName, $label = null): self
{
return (new self())
->setProperty($propertyName)
->setLabel($label)
// this template is used in 'index' and 'detail' pages
->setTemplatePath('admin/field/icon.html.twig')
// this is used in 'edit' and 'new' pages to edit the field contents
// you can use your own form types too
->setFormType(TextType::class)
->addCssClass('field-icon')
// these methods allow to define the web assets loaded when the
// field is displayed in any CRUD page (index/detail/edit/new)
//->addCssFiles('admin/field/field-icon.css')
//->addJsFiles('admin/field/field-icon.js')
;
}
}