Customize EasyAdmin
This commit is contained in:
@@ -3,10 +3,17 @@
|
||||
namespace App\Controller\Admin;
|
||||
|
||||
use App\Entity\Comment;
|
||||
use EasyCorp\Bundle\EasyAdminBundle\Config\Crud;
|
||||
use EasyCorp\Bundle\EasyAdminBundle\Config\Filters;
|
||||
use EasyCorp\Bundle\EasyAdminBundle\Controller\AbstractCrudController;
|
||||
use EasyCorp\Bundle\EasyAdminBundle\Field\AssociationField;
|
||||
use EasyCorp\Bundle\EasyAdminBundle\Field\DateTimeField;
|
||||
use EasyCorp\Bundle\EasyAdminBundle\Field\EmailField;
|
||||
use EasyCorp\Bundle\EasyAdminBundle\Field\IdField;
|
||||
use EasyCorp\Bundle\EasyAdminBundle\Field\TextareaField;
|
||||
use EasyCorp\Bundle\EasyAdminBundle\Field\TextEditorField;
|
||||
use EasyCorp\Bundle\EasyAdminBundle\Field\TextField;
|
||||
use EasyCorp\Bundle\EasyAdminBundle\Filter\EntityFilter;
|
||||
|
||||
class CommentCrudController extends AbstractCrudController
|
||||
{
|
||||
@@ -15,14 +22,42 @@ class CommentCrudController extends AbstractCrudController
|
||||
return Comment::class;
|
||||
}
|
||||
|
||||
/*
|
||||
public function configureCrud(Crud $crud): Crud
|
||||
{
|
||||
return $crud
|
||||
->setEntityLabelInSingular('Conference Comment')
|
||||
->setEntityLabelInPlural('Conference Comments')
|
||||
->setSearchFields(['author', 'text', 'email'])
|
||||
->setDefaultSort(['createdAt' => 'DESC'])
|
||||
;
|
||||
}
|
||||
|
||||
public function configureFilters(Filters $filters): Filters
|
||||
{
|
||||
return $filters
|
||||
->add(EntityFilter::new('conference'));
|
||||
}
|
||||
|
||||
public function configureFields(string $pageName): iterable
|
||||
{
|
||||
return [
|
||||
IdField::new('id'),
|
||||
TextField::new('title'),
|
||||
TextEditorField::new('description'),
|
||||
];
|
||||
yield AssociationField::new('conference');
|
||||
yield TextField::new('author');
|
||||
yield EmailField::new('email');
|
||||
yield TextareaField::new('text')
|
||||
->hideOnIndex()
|
||||
;
|
||||
yield TextField::new('photoFilename')
|
||||
->onlyOnIndex()
|
||||
;
|
||||
|
||||
$createdAt = DateTimeField::new('createdAt')->setFormTypeOptions([
|
||||
'years' => range(date('Y'), date('Y') + 5),
|
||||
'widget' => 'single_text',
|
||||
]);
|
||||
if(Crud::PAGE_EDIT === $pageName) {
|
||||
yield $createdAt->setFormTypeOption('disabled', true);
|
||||
} else {
|
||||
yield $createdAt;
|
||||
}
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user