symfony-2.2

Locale in route prefix

走远了吗. 提交于 2020-01-24 20:07:05
问题 I'm trying to prefix all routes within single controller with _locale but so far I haven't had any success: /** * @Route("/{_locale}/events", requirements={"_locale": "en"}) * @Route("/{_locale}/evenements", requirements={"_locale": "fr"}) */ class SomeController extends Controller{ /** * @Route("/", name="events") */ public function indexAction(){ ... } ... } route:debug does not even list URLs prefixed by second @Route . I tried removing _locale slug altogether but still, route could not be

Undefined variable $output in Symfony Component Console DialogHelper

亡梦爱人 提交于 2020-01-06 07:49:26
问题 I tried to run symfony console command, but I've got an error: Notice: Undefined variable: output in /var/www/.../vendor/symfony/symfony/src/Symfony/Component/Console/Helper/DialogHelper.php line 411 I have no idea, why it went wrong. Can anyone help? 回答1: I've solved the problem: this error appears because exec() and shell_exec functions was disabled in php.ini file. To enable this functions you have to edit this string: disable_functions =exec,passthru,shell_exec,system,proc_open and delete

How to use Repository custom functions in a FormType

感情迁移 提交于 2020-01-04 03:18:19
问题 The problem I'm facing is I have to create a selectbox in a form that holds all the parent entities (Category Entity). Now i managed to do this with: $builder->add('parent', 'entity', array( 'class' => 'KprCentarZdravljaBundle:Category', 'query_builder' => function($repository) use ($param, $catID) { return $repository->createQueryBuilder('p') ->where('p.id != :id AND p.parent = :parent') ->setParameters(array('id' => $param, 'parent' => $catID));}, 'property' => 'name', 'required' => false,

Convention-based routing in Symfony2

北城以北 提交于 2019-12-30 11:15:11
问题 I'm trying to learn learn how routing works in Symfony2, and so far everything I've read has examples like this: blog: path: /blog/{page} defaults: { _controller: AcmeBlogBundle:Blog:index, page: 1 } This routes requests to /blog/123 to the AcmeBlogBundle Blog controller's "index" action, and passes the 123 parameter as the "page" parameter to that controller action. If no page parameter is passed, then the page defaults to 1. That's all well and good, but what if you want to simply have a

FormType default input value in same form

余生长醉 提交于 2019-12-24 22:32:28
问题 I have an Entity named Task and build a Symfony TaskType.php for the form. It is my aim to set the endDate datetime field by default to the input of the startDate datime field (which is required). I tried this, but it doesn't work. $builder->add('name'); $builder->add('startDate', 'datetime'); $builder->add('endDate', 'datetime', array( 'empty_value' => array('year' => 'Year', 'month' => 'Month', 'day' => 'Day'), 'required' => false, 'data' => isset($options['data']) ? $options['data']-

File Uploads with Doctrine

泪湿孤枕 提交于 2019-12-24 15:14:26
问题 I am trying to upload files with Doctrine in Symfony2. I followed all the steps in this tutorial tutorial but whene I submit my form I get no errors but the file is not uploaded and the path in the table "document" is null. This is my entity <?php namespace projet\ClasseBundle\Entity; use Doctrine\ORM\Mapping as ORM; use Symfony\Component\Validator\Constraints as Assert; /** * Projet * * @ORM\Table() * @ORM\Entity(repositoryClass="projet\ClasseBundle\Entity\ProjetRepository") * @ORM

how to overriding fosuserbundle registration form style

拈花ヽ惹草 提交于 2019-12-22 18:15: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 %} {%

SonataAdminBundle : display non crud (statistics)

江枫思渺然 提交于 2019-12-17 17:28:59
问题 I'm using sonata admin bundle to generate my backend, I'm so happy with it that I would like to use my backend to display statistics as well. I guess I can do that by tweaking bundle's views, "standard_layout.html.twig" maybe. Problem is, I can't find examples or even people speaking about it, so I'm wondering, is that possible ? Aren't people speaking about it because it's too simple ? Did you do it ? I really would like to have a single backend, so pls enlighten me ! Thank you, copndz 回答1:

Symfony2.2 render ESI template

送分小仙女□ 提交于 2019-12-14 03:42:36
问题 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? 回答1: 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(

Error “Class 'Twig_SimpleFunction' not found” after upgrade to Symfony 2.2

流过昼夜 提交于 2019-12-11 13:45:55
问题 I recently updated Symfony from 2.1 to 2.2 and now I'm getting error: Error: Class 'Twig_SimpleFunction' not found in vendor/symfony/symfony/src/Symfony/Bundle/SecurityBundle/Twig/Extension/LogoutUrlExtension.php line 41 My composer.json: ... "require": { "php": ">=5.4", "symfony/symfony": "2.2.*", "twig/twig": "1.11.x", "twig/extensions": "1.0.x-dev", "noetix/easy-csv": "dev-master", "symfony/assetic-bundle": "2.*", "symfony/swiftmailer-bundle": "2.*", "symfony/monolog-bundle": "2.*",