标签: easyadmin

如何在 Symfony 5 上使用带有 easyAdmin 3 的 Vich 上传器

我一直在尝试使用 VichUploader 在 Symfony 项目上上传文件,已经在使用 EasyAdmin?3。

我已正确配置所有内容,但出现此错误:

“pieceJointeFile”图像字段必须定义使用 setUploadDir() 方法上传图像的目录。

<?php

namespace App\Entity;

use App\Repository\InventaireRepository;
use DateTime;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\HttpFoundation\File\File;
use Vich\UploaderBundle\Mapping\Annotation as Vich;

My entity

/**
 * @ORM\Entity(repositoryClass=InventaireRepository::class)
 * @Vich\Uploadable
 */
class Inventaire
{
    /**
     * @ORM\Id
     * @ORM\GeneratedValue
     * @ORM\Column(type="integer")
     */
    private $id;

    /**
     * @ORM\ManyToOne(targetEntity=Conducteur::class, inversedBy="inventaires")
     */
    private $conducteur;

    /**
     * @ORM\Column(type="date")
     */
    private $dateInventaire;

    /**
     * @ORM\Column(type="string", length=255)
     */
    private $pieceJointe;

    /**
     * @Vich\UploadableField(mapping="pieceJointe", fileNameProperty="pieceJointe")
     */
    private $pieceJointeFile;

    /**
     * @ORM\Column(type="datetime")
     */
    private …
Run Code Online (Sandbox Code Playgroud)

php symfony vichuploaderbundle easyadmin symfony5

11
推荐指数
2
解决办法
5191
查看次数

Symfony 5 &amp; EasyAdmin 3.0 - 找不到 /admin 路由

我在本地安装了新的 Symfony 5 项目,并添加了 Easy Admin trought Symfony CLI:

symfony composer req admin

我应该有/admin路线但它不见了

我跑:

symfony console cache:clear

symfony composer dump-autoload

rm -rf var/cache/*

symfony console debug:router
 -------------------------- -------- -------- ------ ----------------------------------- 
  Name                       Method   Scheme   Host   Path                               
 -------------------------- -------- -------- ------ ----------------------------------- 
  _preview_error             ANY      ANY      ANY    /_error/{code}.{_format}           
  _wdt                       ANY      ANY      ANY    /_wdt/{token}                      
  _profiler_home             ANY      ANY      ANY    /_profiler/                        
  _profiler_search           ANY      ANY      ANY    /_profiler/search                  
  _profiler_search_bar       ANY      ANY      ANY    /_profiler/search_bar              
  _profiler_phpinfo          ANY      ANY      ANY    /_profiler/phpinfo                 
  _profiler_search_results   ANY      ANY      ANY    /_profiler/{token}/search/results  
  _profiler_open_file …
Run Code Online (Sandbox Code Playgroud)

php symfony easyadmin symfony5

10
推荐指数
3
解决办法
8161
查看次数

FOSUserBundle管理EasyAdminBundle(("用户"实体必须使用"class"选项定义其关联的Doctrine实体类))Symfony

我正在使用Symfony 3.4与FOSUserBundle~2.0和EasyAdminBundle ^ 1.17.一切正常.我可以登录系统并创建用户((当然有推荐行))我使用这个toutaril 但是当我想在EasyAdminBundle.i管理时有这个错误

The "User" entity must define its associated Doctrine entity class using the "class" option.
Run Code Online (Sandbox Code Playgroud)

这是我的config.yml

..
.
.
entities:
            User:
            label: 'user'
            list:
                 actions:
                        - {name: 'delete', label: 'del' }
                        - {name: 'edit' , lable: 'edite'}
                 title: 'user'
                 fields:
                        - username
                        - email
                        - enabled
                        - lastLogin
            class: AppBundle\Entity\User
            form:
                fields:
                    - username
                    - email
                    - enabled
                    - lastLogin
                    # if administrators are allowed to edit users' passwords and roles, add this:
                    - { …
Run Code Online (Sandbox Code Playgroud)

php symfony fosuserbundle symfony-3.4 easyadmin

9
推荐指数
1
解决办法
494
查看次数

Easy Admin - 在Show Action中显示完整的国家/地区名称

我有一个需要一个国家的地址实体.在相关的表格中,我使用的是Symfony的CountryType,它显示了一个用户友好的国家选择,并将其缩写存储在实体中(例如德国的DE或瑞士的CH).

要在管理面板的show动作中显示地址'country,我在以下行中使用以下行easy_admin.yaml:

- { property: country, label: 'address.entity.country' }
Run Code Online (Sandbox Code Playgroud)

问题:

这仅显示缩写而不是国家的实际名称.我怎么能改变呢?

国家地址实体:

/**
 * @ORM\Column(type="string", length=255)
 */
private $country;
Run Code Online (Sandbox Code Playgroud)

symfony symfony2-easyadmin easyadmin

8
推荐指数
1
解决办法
179
查看次数

如何使用简单的管理对列表中的多个字段进行排序?

通过简单的管理,您可以对列表的一个字段进行排序。
Symfony - Easy Admin v2:对实体列表
进行排序 但是有没有办法对我的列表中的多个字段进行排序?

symfony doctrine-orm easyadmin

7
推荐指数
1
解决办法
2143
查看次数

EasyAdmin3:将附加变量传递给 twig-template (编辑页面)

背景

我想在编辑页面中显示与实体无关的信息。根据官方文档可以用configureResponseParameters-function来解决。

问题

所以我将该功能实现到我的 CRUD 控制器中。

  • 在 INDEX twig 模板上:我可以使用/查找变量
  • 在编辑树枝模板上:我无法使用/找到变量

知道为什么吗?

如何将数据传递到我的 EDIT-twig 模板?非常感谢!

我的文件

PersonCrudController.php

class PersonCrudController extends AbstractCrudController {
    public function configureCrud(Crud $crud): Crud {

        $crud->setFormThemes([
            'mystuff/person_edit_form.html.twig', '@EasyAdmin/crud/form_theme.html.twig'
        ]);

        return $crud;
    }

    public function configureFields(string $pageName): iterable {
        // ...
        yield TextField::new('specialDisplay')->setFormTypeOption('mapped', false);
        // ...
    }

    public function configureResponseParameters(KeyValueStore $responseParameters): KeyValueStore
    {
        $responseParameters->set('testtesttest', '123xyz');
        return $responseParameters;
    }
    // ...
}
Run Code Online (Sandbox Code Playgroud)

mystuff/person_edit_form.html.twig

{% block _Person_specialDisplay_row %}
    {{ testtesttest }} {# throws: Variable "testtesttest" does …
Run Code Online (Sandbox Code Playgroud)

crud parameter-passing symfony twig easyadmin

6
推荐指数
0
解决办法
1646
查看次数

EasyAdmin 3 - CollectionField 添加表单条目类型选项?

在我的 CRUD 控制器中,我有一个 CollectionField,它有一个引用 formType 的 entryType 选项

\n
yield CollectionField::new(\'drinks\', \'Boissons\')\n  ->setFormTypeOption(\'by_reference\', false)\n  ->setEntryType(CommandProductItemType::class);\n
Run Code Online (Sandbox Code Playgroud)\n

命令产品项目类型

\n
    public function buildForm(FormBuilderInterface $builder, array $options)\n    {\n\n        $builder\n            ->add(\'product\', EntityType::class, [\n                \'label\' => \'Produit\',\n                \'class\' => Product::class,\n                \'choice_label\' => \'namePrice\',\n            ])\n            ->add(\'quantity\', IntegerType::class, [\n                \'label\' => \'Quantit\xc3\xa9\',\n                \'attr\' => [\n                    \'min\' => 1\n                ]\n            ])\n        ;\n    }\n\n    public function configureOptions(OptionsResolver $resolver)\n    {\n        $resolver->setDefaults([\n            \'data_class\' => CommandProductItem::class,\n            \'category\' => Category::class\n        ]);\n    }\n
Run Code Online (Sandbox Code Playgroud)\n

如何将类别选项从CollectionField项传递到CommandProductItemType

\n

php forms collections symfony easyadmin

6
推荐指数
1
解决办法
869
查看次数

带有过滤器列表的symfony easyadmin表单字段类型实体

我使用 symfony 3.4 和 easycorp/easyadmin-bundle 1.17

这是我的“Quotation”类,“artisan”字段是“Person”实体的“注册中”(person.type = 1):

class Quotation
{
/** others fields... */

/**
 *  1 => 'artisan', 2 => 'customer'
 */
private $type;

/**
 * @ORM\ManyToOne(targetEntity="Person", inversedBy="artisanQuotations", cascade= { "persist" })
 * @ORM\JoinColumn(name="artisan_id", referencedColumnName="id")
 */
private $artisan;

    /** getters and setters ... */
Run Code Online (Sandbox Code Playgroud)

我在使用自定义字段类型的表单字段时遇到问题

form:
    fields:
        ...
        - { property: 'artisan', label: '', type: 'AppBundle\Form\Field\ArtisanType' }
Run Code Online (Sandbox Code Playgroud)

我创建了这个表单字段类型,以便能够通过 query_builder 过滤列表:

public function buildForm(FormBuilderInterface $builder, array $options)
{
    $builder->add('artisan', EntityType::class, array(
        'class' => 'AppBundle:Person',
        'label' => false,
        'query_builder' …
Run Code Online (Sandbox Code Playgroud)

symfony easyadmin

5
推荐指数
1
解决办法
3197
查看次数

easyadmin 捆绑在可排序字段上对自定义生成的列进行排序

有像这样的 EasyAdmin 捆绑配置,并添加了列表字段,其中一些添加了标记为可排序,一些则不是。并且无法找到如何创建可排序字段:1)这是来自另一个实体的关系字段。IE OtherEntityName.columnName; 2) 这是从 ie 2 个字段中自定义生成的字段(这是由实体中的和字段fullname组成的)firstnamelastnameEntityName

easy_admin:
    entities:
        EntityName:
            class: App\Entity\EntityName
            label: EntityName
            list:
                fields:
                    - {property: id, sortable: true}
                    - {property: createdAt, sortable: true}
                    - {property: fullName, sortable: true}
                    - {property: OtherEntityName.columnName, sortable: true}
Run Code Online (Sandbox Code Playgroud)

找不到如何使其可排序,但默认情况下不排序。需要使其管理员操作进行排序,而不是默认情况下,如本例所示:

easy_admin:
    entities:
        EntityName:
            class: App\Entity\EntityName
            label: EntityName
            list:
                fields:
                    - {property: id, sortable: true}
                    - {property: createdAt, sortable: true}
                    - {property: fullName, sortable: true}
                    - {property: OtherEntityName.columnName, sortable: true}
                sort: ['createdAt', 'ASC']
Run Code Online (Sandbox Code Playgroud)

php symfony php-7 symfony4 easyadmin

5
推荐指数
0
解决办法
2433
查看次数

在 Symfony 5 中使用 Composer 安装 EasyAdmin 时出现问题

我在 Symfony 5 中启动了一个新项目,并尝试安装 EasyAdmin,composer require easycorp/easyadmin-bundle但发现了一个问题。

作曲家日志:

./composer.json has been updated
Loading composer repositories with package information
Updating dependencies (including require-dev)
Restricting packages listed in "symfony/symfony" to "5.1.*"
Your requirements could not be resolved to an installable set of packages.

  Problem 1
    - Conclusion: don't install easycorp/easyadmin-bundle v3.1.3
    - Conclusion: don't install easycorp/easyadmin-bundle v3.1.2
    - Conclusion: don't install easycorp/easyadmin-bundle v3.1.1
    - Conclusion: don't install easycorp/easyadmin-bundle v3.1.0
    - Conclusion: don't install easycorp/easyadmin-bundle v3.0.2
    - Conclusion: don't install easycorp/easyadmin-bundle …
Run Code Online (Sandbox Code Playgroud)

symfony composer-php easyadmin

5
推荐指数
1
解决办法
2624
查看次数