symfony4

How to translate symfony form error messages?

走远了吗. 提交于 2020-02-25 06:17:50
问题 for symfony standalone translation component I use: $translator = new Translator('fr_FR'); $translator->addLoader('php', new \Symfony\Component\Translation\Loader\PhpFileLoader()); $translator->addResource('php', ROOT.'/translations/messages.fr.php', 'fr_FR'); $twig->addExtension(new TranslationExtension($translator)); It is working fine to translate symfony form labels. To translate symfony form constraint errors I use: ->add('firstname', TextType::class, [ 'constraints' => [new Assert

How to translate symfony form error messages?

柔情痞子 提交于 2020-02-25 06:17:26
问题 for symfony standalone translation component I use: $translator = new Translator('fr_FR'); $translator->addLoader('php', new \Symfony\Component\Translation\Loader\PhpFileLoader()); $translator->addResource('php', ROOT.'/translations/messages.fr.php', 'fr_FR'); $twig->addExtension(new TranslationExtension($translator)); It is working fine to translate symfony form labels. To translate symfony form constraint errors I use: ->add('firstname', TextType::class, [ 'constraints' => [new Assert

GET max value form since DB symfony 4

蹲街弑〆低调 提交于 2020-02-25 04:23:14
问题 Sorry to disturb you but I would like to obtain a max value for a form validation for example it can be a numeric field but the validation of type range MaxValue will have to be retrieved in the database I explain myself for example I wish to reserve a transport the max value by default is 4 for 4 remaining places but if for this vehicle there are 3 places left, the validation would have to pass to 3 I tried to go through entitytype with events but it didn't change anything to my problem it

GET max value form since DB symfony 4

痴心易碎 提交于 2020-02-25 04:21:43
问题 Sorry to disturb you but I would like to obtain a max value for a form validation for example it can be a numeric field but the validation of type range MaxValue will have to be retrieved in the database I explain myself for example I wish to reserve a transport the max value by default is 4 for 4 remaining places but if for this vehicle there are 3 places left, the validation would have to pass to 3 I tried to go through entitytype with events but it didn't change anything to my problem it

Symfony 4 - How tu use service.yaml parameter from within Entity

扶醉桌前 提交于 2020-02-07 00:07:27
问题 I'm trying to use a parameter that i've set in service.yaml as such : parameters: app.path.users_profile_picture: uploads/users/profile-picture Directly from within a User Entity, And I can't figure out how to do this ? 回答1: I'm not sure of what you're trying to do or why, it does look like there may be a better way of achieving what you want. That being said, it is possible to use a parameter from your services.yaml in an entity, but you can't inject it directly in the entity's constructor.

The class 'App\Entity\Users' was not found in the chain configured namespaces

对着背影说爱祢 提交于 2020-02-04 11:48:05
问题 I want to add an Authentication system with Symfony 4. I'm using an Mssql Database, who its already created and populated. This is not the first time, i'm using it. But this is the first time i have issue. I imported all my entities, from my database, especially the Users Entity. I also configurated LoginFormAuthenticator.php, and my security.yml Users.php <?php namespace App\Entity; use Doctrine\ORM\Mapping as ORM; use Symfony\Component\Security\Core\User\UserInterface; /** * Users * * @ORM

The class 'App\Entity\Users' was not found in the chain configured namespaces

五迷三道 提交于 2020-02-04 11:46:16
问题 I want to add an Authentication system with Symfony 4. I'm using an Mssql Database, who its already created and populated. This is not the first time, i'm using it. But this is the first time i have issue. I imported all my entities, from my database, especially the Users Entity. I also configurated LoginFormAuthenticator.php, and my security.yml Users.php <?php namespace App\Entity; use Doctrine\ORM\Mapping as ORM; use Symfony\Component\Security\Core\User\UserInterface; /** * Users * * @ORM

New collection element overwrites the last element if it already exists when updating an entry

流过昼夜 提交于 2020-01-25 09:22:24
问题 so I have a Mission entity connected to an Option entity through a ManyToMany relationship. At the time of creating a new mission it is possible to add several options (this point is ok). Now when updating a mission, when I add a new option it overwrites the last option if it already exists otherwise it fits well. I want to be able to add as many options when modifying a mission without overwriting the last existing option. I post my code: Mission entity : /** * @var ArrayCollection $options

Sylius: How to reference your own twig template in a grid?

早过忘川 提交于 2020-01-25 06:48:09
问题 This is not a duplicate of e.g. Referencing a template in Twig / Symfony2 because creating bundles as applications is deprecated/not recommended anymore and therefore the answer is not applicable anymore. How do I reference my own template in a Sylius grid? What I tried: 1. options: template: "@App/Order/Grid/Field/channel.html.twig" 2. options: template: ":Order/Grid/Field:channel.html.twig" 3. options: template: "templates/Order/Grid/Field/channel.html.twig" 4. options: template: "Order

Symfony: How can I get hold of tagged services and processed configuration at the same time?

坚强是说给别人听的谎言 提交于 2020-01-24 22:10:13
问题 I'm trying to symfony Configuration to determine how to wire some tagged services, but am running into problems. I've tried to boil the problem down into as little code as possible to help explain, but still - sorry for the length! Here's the configuration part of things... class Configuration implements ConfigurationInterface { public function getConfigTreeBuilder() { $treeBuilder = new TreeBuilder('acme_test'); $treeBuilder ->getRootNode() ->addDefaultsIfNotSet() ->children() ->scalarNode(