symfony4

Use query_builder on CollectionType in symfony4 forms?

☆樱花仙子☆ 提交于 2021-02-08 03:31:22
问题 In a symfony 4 form, I need to use something like a query_builder option that is available on EntityType but from a CollectionType . There is a similar question here with no good answers. In my project, each Site entity has many Goal . Each Goal has a numeric goal and a specific date. I'd like to edit the goals of a site for a specific date only. The problem is that a CollectionType form pulls all goals to show in the form, but I only want to pull the goals for a given date. How? There is no

Calls to isSumbitted() and isValid() result in “undefined method” error

这一生的挚爱 提交于 2021-02-05 12:26:08
问题 I have a Symfony form that is created from createFormBuilder() in the controller. But under two IF statements the form should carry two different set of fields. My Symfony version is 3.4. /src/AppBundle/Controller/DefaultController.php Ex: This is the basic form. $form = $this->createFormBuilder() ->add('name', TextType::class, ['required' => true]]) ->add('email', EmailType::class, ['required' => true]]) ->getForm(); if ($form->isSubmitted() && $form->isValid()) { ... ... ... } Now I need to

Symfony 5 (Including 4) using Gedmo Doctrine Extension for SoftDelete

前提是你 提交于 2021-02-05 09:26:29
问题 I have tried to use soft delete (Using gedmo/doctrine-extensions) for some Entities in Symfony 5, and got some troubles: Listener "SoftDeleteableListener" was not added to the EventManager! Compile Error: App\Entity\Admin and Gedmo\SoftDeleteable\Traits\SoftDeleteableEntity define the same property ($deletedAt) in the composition of App\Entity\Admin. However, the definition differs and is considered incompatible. Class was composed This is what I tried, and it runs well Install gedmo/doctrine

dump_destination in symfony/debug-bundle config

ε祈祈猫儿з 提交于 2021-01-29 12:28:54
问题 In my team we work with SF4 and use .env.dist (and so .env) for developer specific config. When we develop we find symfony/var-dumper very useful, however some devs like to dump in browser and some in console using server:dump command which comes with symfony/debug-bundle. It's very annoying to comment out / uncomment debug.dump_destination key over and over after pulling from remote or worry about conflicts when current remote HEAD happens to have this file also edited. I did my best to

How to create custom update operation that can be rejected depending on the entity current status?

你离开我真会死。 提交于 2021-01-29 10:57:18
问题 I'm creating a custom PUT operation. Not using the built-in operations because the affected property is not included in the default normalization for this entity, and also because this operation has a few side-effects that go beyond this entity/model. Additionally, the update operation should only succeed if the current state of the entity on the DB matches certain expectations. E.g. for the entity class Lead { /** * @ORM\Column(type="integer", nullable=true) * @Groups({"lead", "leadReject" }

can't create a symfony 4 project with “symfony/website-skeleton”

别来无恙 提交于 2021-01-29 10:43:33
问题 I have an error message when I create the project with --full Symfony CLI version v4.21.3 (2020-12-11T09:19:56+0000 - stable) PHP 7.1.9 (cli) (built: Aug 30 2017 18:34:46) ( ZTS MSVC14 (Visual C++ 2015) x64 ) Copyright (c) 1997-2017 The PHP Group Zend Engine v3.1.0, Copyright (c) 1998-2017 Zend Technologies Composer version 2.0.8 2020-12-03 17:20:38 And command using symfony new blog --full error message Script cache:clear returned with error code 255 !! !! // Clearing the cache for the dev

Error when loading parameters into Symfony bundle

雨燕双飞 提交于 2021-01-29 06:42:39
问题 I get following error: There is no extension able to load the configuration for "upload_images" (in "/var/www/vhosts/diabetigraph-dev/vendor/verzeilberg/upload-images/src/Resources/services.yaml"). Looked for namespace "upload_images", found "none" This are my files: services.yaml services: verzeilberg\UploadImagesBundle\Service\Rotate: autowire: true upload_images: version: 100 Configuration namespace verzeilberg\UploadImagesBundle\DependencyInjection; use Symfony\Component\Config\Definition

Use two entitymanagers does not work with repository

烂漫一生 提交于 2021-01-28 11:01:04
问题 I'm using two Entitymanagers to work with two databases. The problem is that I can't set the correct entitymanager for my repository(it uses the default entitymanager). When I persist the entity to the database, it works fine (with the wp entitymanager) . How can I use the wp entitymanager? The problem is similar to this one. The solution didn't work Use different Entity Manager in the Repository of specific Entity objects doctrine.yaml orm: default_entity_manager: default auto_generate_proxy

WHERE … IN query with sub-query in Doctrine queryBuilder or equivalent

穿精又带淫゛_ 提交于 2021-01-28 07:01:34
问题 In my Symfony 4 project I have a User entity and a UserRepository . I'm trying to implement the equivalent of this SQL query in the QueryBuilder (Doctrine 2) or even in DQL . SELECT * FROM user WHERE account_manager_id IN (SELECT id FROM user WHERE account_manager_id = :managerAdminId AND roles LIKE '%ROLE_MANAGER%') Or maybe use a different syntax. I tried different things, but couldn't figure out how to write the WHERE ... IN with the sub-query. This is all I could come up with, which I don

PUT operation creates new embedded document instead of updating it on Api Platform

随声附和 提交于 2021-01-28 06:37:23
问题 I am stuck on an issue I cannot solve for few days now. As said in the title, Api Platform PUT operation based on annotations doesn't work as expected with regards to partial update on embedded document with MongoDB ODM. Indeed, despite all the different configurations I tried, I didn't succeed in updating an embedded document already set in a parent document. I tried to change annotations in relevant documents, for example by changing normalization and denormalization groups, by trying