我一直在尝试使用 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) 我在本地安装了新的 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) 我正在使用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) 我有一个需要一个国家的地址实体.在相关的表格中,我使用的是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 - Easy Admin v2:对实体列表
进行排序 但是有没有办法对我的列表中的多个字段进行排序?
我想在编辑页面中显示与实体无关的信息。根据官方文档可以用configureResponseParameters-function来解决。
所以我将该功能实现到我的 CRUD 控制器中。
知道为什么吗?
如何将数据传递到我的 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 控制器中,我有一个 CollectionField,它有一个引用 formType 的 entryType 选项
\nyield CollectionField::new(\'drinks\', \'Boissons\')\n ->setFormTypeOption(\'by_reference\', false)\n ->setEntryType(CommandProductItemType::class);\nRun 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 }\nRun Code Online (Sandbox Code Playgroud)\n如何将类别选项从CollectionField项传递到CommandProductItemType?
\n我使用 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) 有像这样的 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) 我在 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) easyadmin ×10
symfony ×10
php ×5
symfony5 ×2
collections ×1
composer-php ×1
crud ×1
doctrine-orm ×1
forms ×1
php-7 ×1
symfony-3.4 ×1
symfony4 ×1
twig ×1