Artisan Développeur

Qualité, amélioration continue, agilité.

Symfony Ajax populated ENTITY field handle

If you use an ENTITY type field in your formType, and if you populated this field with Ajax, you can have this error :

Symfony\Component\Validator\ConstraintViolation

Object(Symfony\Component\Form\Form).children[tag] = 2

Caused by:

Symfony\Component\Form\Exception\TransformationFailedException

Unable to reverse value for property path "tag": The choice "2" does not exist or is not unique

Caused by:

Symfony\Component\Form\Exception\TransformationFailedException

The choice « 2 » does not exist or is not unique

I have a user Entity with a ManyToOne relation with a Tag entity.

In my form, when I select the user, an AJAX request retrieve all the user’s tag, and add the options on the select element.

But Symfony doesn’t know about these values, and the validation fails when the form is submitted.

After lot of tests, with data transformer, listener, both, I succeed with a simple event subscriber following this symfony doc page http://symfony.com/doc/2.7/form/events.html#event-subscribers.

Basically, the event subscriber occurs on the pre_submit, take the ID of the TAG, and add an entity field with a custom query who retrieved the good tag entity.

Enough talk, more code 🙂

Permission denied creating inbox file in /var/mail – dovecot

Hi !

this morning I have seen this error :

Permission denied creating inbox file in /var/mail

I have done a basic setup of dovecot + postfix.
At the time to test my new mailbox, after added a new user, no luck, and this message in the log.

Solution is really simple, as the mailboxes are owned by the user, and the group is set to « mail »

[pastacode lang= »bash » manual= »-rw——-%20%201%20amavis%20%20%20%20mail%20%20%20%20836%20Jun%2019%20%202015%20amavis%0A-rw——-%20%201%20jenkins%20%20%20mail%20442270%20Sep%2030%2000%3A00%20jenkins%0A-rw——-%20%201%20root%20%20%20%20%20%20mail%20634190%20Sep%2030%2000%3A12%20root%0A-rw——-%20%201%20technique%20mail%20%20%20%20%20%200%20Sep%2030%2014%3A43%20technique » message= » » highlight= » » provider= »manual »/]

You just need to add your user to the « mail » group :

[pastacode lang= »bash » manual= »addgroup%20technique%20mail » message= » » highlight= » » provider= »manual »/]

Where « technique » is my username.

That’s all !

 

debian, ubuntu under KVM really slow

I can’t remember where I found this, so, if you are the original author of this solution, say hello, with the original link 🙂

If you install a debian or an ubuntu, you can experience some bad perf.

I use virt-manager to manage my vm’s.

Simple file with some options for the QXL driver fix the problem.

[pastacode lang= »bash » manual= »nano%20%2Fusr%2Fshare%2FX11%2Fxorg.conf.d%2Fqxl.conf » message= » » highlight= » » provider= »manual »/]

Inside the file :

[pastacode lang= »bash » manual= »Section%20%22Device%22%0A%20%20%20%20Identifier%20%22qxl%22%0A%20%20%20%20Driver%20%22qxl%22%0A%20%20%20%20Option%20%22ENABLE_SURFACES%22%20%22False%22%0AEndSection » message= » » highlight= » » provider= »manual »/]

And reboot !