symfony-2.2

how to overriding fosuserbundle registration form style

房东的猫 提交于 2019-12-06 11:52:17
I want to use bootstrap style apply in fosuserbundle registration form.and the login cant overriding,but because of registration form use "{{ form_widget(form) }}",so I can't overriding it,I use symfony2.2,I also test use form theme,like this {% block form_row %} {% spaceless %} <div class="control-group"> {{ form_label(form, label|default(null),{ 'attr': {'class': 'control-label'} }) }} {{ form_errors(form) }} <div class="controls">{{ form_widget(form) }}</div> </div> {% endspaceless %} {% endblock form_row %} and in form template the code is {% form_theme form with '@user/form/fields.html' %

Adding a form error in an EventListener

风格不统一 提交于 2019-12-06 01:50:21
I have a Symfony 2.2 based application with a form that has a field that is only required based on another field in the form. I bound an EventListener to catch when the form is submitted so I can verify if the 'required' field is actually not needed when the form is submitted. I've noticed that I can't set a FormError inside the PRE_BIND form event. Doing so doesn't show the error, but if I bind to the BIND event listener then the form error is displayed properly but I don't want to wait until the BIND event to check for my errors (I don't want the potential of bad data being bound to my

Bug into fosuserbundle when double click on confirmation link?

故事扮演 提交于 2019-12-06 00:52:48
问题 I just begin to use fosuserbundle, today I activate the confirmation register link. It works great, but if the user click a second time on the confirmation link in the email, he get that error : The user with confirmation token "3hiqollkisg0s4ck4w8g0gw4soc0wwoo8ko084o4ww4sss8o4" does not exist 404 Not Found - NotFoundHttpException I think this error should be handle by the bundle, no ? Thanks 回答1: Here's the code for overriding the action. Basically just copied part of the actual FOS action

Symfony2 custom authentication provider bad credentials

我与影子孤独终老i 提交于 2019-12-04 21:05:48
I'm implementing a custom authentication provider for using an external api following roughly the cookbook on the symfony website. It works almost everything correctly, the listener listens the login form properly, then it calls the authenticate function which returns the authenticated token, the problem is that even if i set a authenticated token to the securityContextInterface, the system returns to the login page with wrong credentials. Under the code i've used What could it be? security.yml firewalls: dev: pattern: ^/(_(profiler|wdt)|css|images|js)/ security: false login: pattern: ^/app

Symfony2.2 render ESI template

不羁的心 提交于 2019-12-04 17:26:12
From the documentation , there is no example of how to render a template inside template using ESI. Is it possible to do that? For example, I have a template index.html.php and I want to render form.html.php template with ESI. How to do that? As the documentation page you provided, you can render one controller within another using: {{ render_esi(controller('YourBundle:Default:news', { 'max': 5 })) }} You can also use a route name instead of the controller reference: {{ render_esi(url('latest_news', { 'max': 5 })) }} However, you will need to set up a gateway cache for ESI to work. 来源: https:/

Bug into fosuserbundle when double click on confirmation link?

邮差的信 提交于 2019-12-04 06:12:44
I just begin to use fosuserbundle, today I activate the confirmation register link. It works great, but if the user click a second time on the confirmation link in the email, he get that error : The user with confirmation token "3hiqollkisg0s4ck4w8g0gw4soc0wwoo8ko084o4ww4sss8o4" does not exist 404 Not Found - NotFoundHttpException I think this error should be handle by the bundle, no ? Thanks Here's the code for overriding the action. Basically just copied part of the actual FOS action and modded. Create a RegistrationController.php file in your user bundle's controller folder and put the

use PHPExcel with composer and Symfony2.2

﹥>﹥吖頭↗ 提交于 2019-12-03 21:36:02
问题 I found this on SO: How to use PHPExcel correctly with Symfony 2 This works, but I want to use it with composer. The first part I already solved: to load PHPExcel for a special tag (the last stable release) I don't find out how to fetch a tag with this syntax: "repositories": [ { "type": "vcs", "url": "https://github.com/umpirsky/SyliusAssortmentBundle" } ] So I use the Package notation: I found out, the reference should be the tag name on github. And the version cannot be the same value

Symfony2 -> Twig -> Form -> Field -> Set rendered = true

怎甘沉沦 提交于 2019-12-03 16:07:05
问题 i have a simple problem. I have a form with a field for example: $builder ->add('x') ->add('y') ->add('z') ; In my twig files i used multiple blocks and i want to stop render fields... I view the b.html.twig file! a.html.twig {% block body %} {% block form %} {{ form_widget(form) }} {% endblock form %} {% endblock body %} b.html.twig {% block form %} {{ form.x.set('rendered', true) | default() }} {{ parent() }} {% endblock form %} If i remove the "default()" i get the error, that the object

Check if ArrayCollection is empty

≡放荡痞女 提交于 2019-12-03 09:12:33
问题 I have an Entity Order which hold Suppliers in an Arraycollection. In my controller i want to check if this arraycollection is empty: $suppliers = $order->getSuppliers(); I tried: if(!($suppliers)) {} if(empty($suppliers)) {} Any ideas? 回答1: Doctrine ArrayCollection has a method isEmpty that will do what you are looking for. if ($suppliers->isEmpty()) { } Take a look at the documentation for it here 回答2: You can also use the count() PHP function: if (count($suppliers) < 1) { } 来源: https:/

Symfony2 -> Twig -> Form -> Field -> Set rendered = true

喜夏-厌秋 提交于 2019-12-03 05:38:10
i have a simple problem. I have a form with a field for example: $builder ->add('x') ->add('y') ->add('z') ; In my twig files i used multiple blocks and i want to stop render fields... I view the b.html.twig file! a.html.twig {% block body %} {% block form %} {{ form_widget(form) }} {% endblock form %} {% endblock body %} b.html.twig {% block form %} {{ form.x.set('rendered', true) | default() }} {{ parent() }} {% endblock form %} If i remove the "default()" i get the error, that the object cant be converted to a string. And actually the form renders all fields... Inclusive the x field. But