symfony-2.3

How to add bundles in the Admin Dashboard Symfony2

时光总嘲笑我的痴心妄想 提交于 2019-12-12 01:29:45
问题 I'm working on Sonata Admin bundles. I've configure the Admin Dashboard and the following components are showing in the "Symfony CMF" group, Here's the snapshot, I've gone through the Symfony CMF sandbox site, http://cmf.liip.ch/en/admin/dashboard In this dashboard there are some other bundles like , Simple Block Container Block etc are appearing. Here's the snapshot, I want to add the Content items as shown in the above pic in my "Symfony CMF" group. How to do it ? Here's my config.yml,

Getting doctrine dbal is null on app initialization

北城余情 提交于 2019-12-11 16:17:11
问题 I was using Authentication success handler to populate some values on session on every success login. I wanted some database operation to be done so i pass @doctrine.dbal.default_connection from my config file. Here is my config file where i override success_handler function. services: security.authentication.success_handler: class: XYZ\UserBundle\Handler\AuthenticationSuccessHandler arguments: ["@security.http_utils", {}, @doctrine.dbal.default_connection] tags: - { name: 'monolog.logger',

Symfony JsFormValidatorBundle run validation on custom event

我的未来我决定 提交于 2019-12-11 12:10:58
问题 I am using JsFormValidatorBundle bundle and liked it very much. Validation works when submit is clicked but I want validation to work immediately after field change without submitting the form I want to run validation on custom event as below: $('form') .find('input, select, textarea') .change(function(){ $(this).jsFormValidator('validate'); }) .jsFormValidator({ showErrors: function(errors, sourceId) { var list = $(this).next('span.help-block'); list.find('.' + sourceId).remove(); if(errors

Problems try encode entity to json

邮差的信 提交于 2019-12-11 11:24:25
问题 im try encode an Doctrine entity as JSON string, to send as Ajax response. So, i check the doc: The Serializer Component I try with this code: $em = $this->getDoctrine()->getManager(); // Get the entities repository $sesiones_registradas = $em->getRepository('AuditBundle:AuditSession')->findAll(); // Instance the object $serializer = new Serializer(array(new JsonEncoder()),array(new GetSetMethodNormalizer())); // Convert only an item foreach($sesiones_registradas as $sesion){ echo $serializer

Mapping FAIL - The entity-class 'PI\UnidadBundle\Entity\HorasPorUnidad' mapping is invalid

*爱你&永不变心* 提交于 2019-12-11 08:33:25
问题 I'm having a problem here and I don't know how to fix it. See I have this two entities: <?php namespace PI\ProyectoBundle\Entity; use Doctrine\ORM\Mapping as ORM; use Doctrine\ORM\Event\LifecycleEventArgs; /** * @ORM\Entity * @ORM\Table(name="proyectos") * @ORM\Entity(repositoryClass="PI\ProyectoBundle\Entity\Repository\ProyectosRepository") * @ORM\HasLifecycleCallbacks */ class Proyectos { /** * @ORM\Id * @ORM\Column(type="integer") */ protected $id; /** * @ORM\Column(type="string", length

Execute function after User Login Symfony 2.3

青春壹個敷衍的年華 提交于 2019-12-11 02:42:01
问题 I am trying to execute a function after user login in FOSUserBundle, in my config.yml I set the service: services: authentication.success.listener: class: MyCompany\MyBundle\EventListener\AuthenticationEventListener arguments: [@router] tags: - { name: kernel.event_subscriber } Then, I create the Listener class with the methods: <?php namespace MyCompany\MyBundle\EventListener; use Symfony\Component\EventDispatcher\EventSubscriberInterface; use Symfony\Component\Routing\Generator

Activate StringLoader Twig Extension in Symfony

﹥>﹥吖頭↗ 提交于 2019-12-10 17:08:19
问题 I'm trying to active the Twig StringLoader Extension in a Symfony 2.3 project but just can't get the yaml-syntax right. This post refers to the answer by Heyflynn on a post dealing with the exact same problem but providing a solution that just does not work (for me). Writing the following lines in my app/config/config.yml just gives me the exception below: # app/config/config.yml acme.twig.extension.loader: class: Twig_Extension_StringLoader tags: - { name: 'twig.extension' } Gives me this:

Symfony2 Forms BooleanToStringTransformer Issue

↘锁芯ラ 提交于 2019-12-10 16:43:19
问题 I have a boolean field that I've put in a form as a choice field (yes or no). I would get 0 or 1 without data transformer. I added a view BooleanToStringTransformer (which seemed reasonable) : $builder ->add( $builder->create('myBooleanField', 'choice', array( 'choices' => array(true => 'Yes', false => 'No'), )) ->addViewTransformer(new BooleanToStringTransformer('1')) ) And when I try to display the form, I get the error "Expected a Boolean.". My field is set to false before creating the

Symfony 2: How to render date field without a day?

可紊 提交于 2019-12-10 16:13:10
问题 I'm trying to build form with date field, where user can pick a month and year only (without day of month), but i can't figure out how to achieve this. public function buildForm(FormBuilderInterface $builder, array $options) { $builder->add( 'month', 'date', array( 'label' => 'Month & year', 'input' => 'array', 'widget' => 'choice', )); $builder->add('submit', 'submit'); } Ideal result is two dropdown lists: list of months (number representation) and list of years (4 digit, 5 last years). I

Symfony HttpFoundation UploadedFile “not uploaded due to unknown error” when using Doctrine DataFixtures

♀尐吖头ヾ 提交于 2019-12-09 18:29:47
问题 I've been using my Attachment entity based on the cookbook recipie How To Handle File Uploads With Doctrine in Symfony 2.3. It works well, even in functional tests. However using it with Doctrine DataFixtures is causing me problems. [Symfony\Component\HttpFoundation\File\Exception\FileException] The file "o-rly-copy.jpg" was not uploaded due to an unknown error. This was not helpful, however I did run php app/console doctrine:fixtures:load -v to bring up a stack trace and it appears the