symfony-2.1

SQLSTATE[28000] [1045] Access denied for user 'root'@'localhost' (using password: NO)

放肆的年华 提交于 2019-11-28 06:58:53
问题 I´m working with symfony 2.1.2, FOSuserBundle, SonataAdminBundle, SonataUserBundle and SonataMediaBundle. The problem is that I cannot access to my database and get this error. This is my parameters.yml parameters: database_driver: pdo_mysql database_host: localhost database_port: null database_name: superlinea database_user: root database_password: !Admin1234 mailer_transport: smtp mailer_host: localhost mailer_user: null mailer_password: null locale: en secret:

Sonata Admin Bundle: DatePicker range

三世轮回 提交于 2019-11-28 06:51:48
How would I create a doctrine_orm_datetime_range filter in the Sonata Admin Bundle which uses the jQuery UI datepicker? I tried the following, but it doesn't work: protected function configureDatagridFilters(DatagridMapper $datagridMapper) { $datagridMapper ->add('datumUitgevoerd', 'doctrine_orm_datetime', array('widget' => 'single_text'), null, array('required' => false, 'attr' => array('class' => 'datepicker'))) ; } pulzarraider UPDATED 2016-02-02 If you are using 3.* Symfony the following twig configuration must be used: # app/config/config.yml twig: # ... form_themes: - 'SonataCoreBundle

Validating dynamically loaded choices in Symfony 2

|▌冷眼眸甩不掉的悲伤 提交于 2019-11-28 06:26:14
I have a choice field type named *sub_choice* in my form whose choices will be dynamically loaded through AJAX depending on the selected value of the parent choice field, named *parent_choice*. Loading the choices works perfectly but I'm encountering a problem when validating the value of the sub_choice upon submission. It gives a "This value is not valid" validation error since the submitted value is not in the choices of the sub_choice field when it was built. So is there a way I can properly validate the submitted value of the sub_choice field? Below is the code for building my form. I'm

Symfony2 validation doesn't work when Entity Relationships/Associations

我与影子孤独终老i 提交于 2019-11-28 03:48:23
问题 controller public function indexAction(Request $request) { $user = $this->container->get('security.context')->getToken()->getUser(); $owner = $user->getId(); $first = new First(); $first->setOwner($owner); $second = new Second(); $second->setOwner($owner); $second->setFirst($first); $form = $this->createForm(new SecondType(), $second); if ($request->getMethod() == 'POST') { $form->bindRequest($request); if ($form->isValid()) { $em = $this->get('doctrine')->getEntityManager(); $em->persist(

JMSSerializerBundle. no control over third party meta data

廉价感情. 提交于 2019-11-27 19:04:59
I have two entities I wish to serialize with the JMSSerializerBundle. The Music Entity has a mapping-file with exclusion_policy: NONE . The Music entity has a field of the entity User from FOSUserBundle . The User entity has a mapping-file with exclusion_policy: ALL with a few fields set to expose: true , so they will be serialized. The problem is, the User field gets fully serialized. It does not matter if I change the mapping-file of the User entity. This is how it looks: #My/Bundle/Resources/config/serializer/Entity.Music.yml xxx\xxx\Entity\Music: exclusion_policy: NONE #My/Bundle/Resources

Symfony 2: How do I check if a user is not logged in inside a template?

和自甴很熟 提交于 2019-11-27 17:02:30
In Symfony 2 templates (using Twig), how can I effectively check whether a user is not logged in? I don't want to use ROLE checks. I want a straightforward way to check if a user is not logged in. I'm aware that comparing app.user.username with anon works, but that just doesn't feel right to me. Checksum You can check if app.user is set. {% if app.user %} # user is logged in {% else %} # user is not logged in {% endif %} Anil Although the current answer answers the OP's question, I would like to add more details. I understand the OP did not want to check roles, but I am including them so other

Streaming a Response in Symfony2

耗尽温柔 提交于 2019-11-27 15:04:21
问题 I am trying this example from the doc: Streaming a Response in Symfony2. /** * @param Request $request * @return Response $render * @Route("/streamedResponse", name="streamed_response") * @Template("AcmeTestBundle::streamedResponse.html.twig") */ public function streamedResponseAction(Request $request) { $response = new StreamedResponse(); $response->setCallback(function () { echo 'Hello World'; flush(); sleep(3); echo 'Hello World'; flush(); }); return $response; } This outputs everything at

When are user roles refreshed and how to force it?

谁都会走 提交于 2019-11-27 12:17:00
问题 First off, I'm not using FOSUserBundle and I can't because I'm porting a legacy system which has its own Model layer (no Doctrine/Mongo/whatsoever here) and other very custom behavior. I'm trying to connect my legacy role system with Symfony's so I can use native symfony security in controllers and views. My first attempt was to load and return all of the user's roles in the getRoles() method from the Symfony\Component\Security\Core\User\UserInterface . At first, it looked like that worked.

How to get list of all routes of a controller in Symfony2?

时光怂恿深爱的人放手 提交于 2019-11-27 11:39:27
I have a controller which implements all routes/URL(s) . I had the idea to offer a generic index over all help-pages. Is there a way to get all routes defined by a controller (from within a controller) in Symfony2 ? You could get all of the routes, then create an array from that and then pass the routes for that controller to your twig. It's not a pretty way but it works.. for 2.1 anyways.. /** @var $router \Symfony\Component\Routing\Router */ $router = $this->container->get('router'); /** @var $collection \Symfony\Component\Routing\RouteCollection */ $collection = $router->getRouteCollection(

Use a conditional statement when creating a form

只谈情不闲聊 提交于 2019-11-27 11:00:42
问题 I would like to use a conditional statement when creating a form in Symfony. I am using a choice widget in general case. If the user selects the option " Other ", I would like to display an additional text box widget . I suppose this can be done in javascript, but how can I still persist the data from 2 widgets into the same property in my entity? I have this so far: $builder->add('menu', 'choice', array( 'choices' => array('Option 1' => 'Option 1', 'Other' => 'Other'), 'required' => false, )