symfony-2.3

Symfony2 Form Builder Select Across Join Table with Metadata

允我心安 提交于 2019-12-03 08:37:47
问题 I have 3 entities: [Member] ----OneToMany----> [MemberCategory] ---ManyToOne---> [Category] This works well as far as fetching results from the database, but I can't get the Form Builder to build a correct form controls. I want a list of all categories with checkboxes that are checked for those categories that are used by the member. Eventually I want to add the priority field. Member class Member { protected $id; @ORM\OneToMany(targetEntity="MemberCategory", mappedBy="member") protected

Calling $builder->getData() from within a nested form always returns NULL

邮差的信 提交于 2019-12-03 06:48:00
I'm trying to get data stored in a nested form but when calling $builder->getData() I'm always getting NULL. Does anyone knows what how one should get the data inside a nested form? Here's the ParentFormType.php: class ParentFormType extends AbstractType { public function buildForm(FormBuilderInterface $builder, array $options) { $builder->add('files', 'collection', array( 'type' => new FileType(), 'allow_add' => true, 'allow_delete' => true, 'prototype' => true, 'by_reference' => false ); } } FileType.php class FileType extends AbstractType { public function buildForm(FormBuilderInterface

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

Symfony2 Form Builder Select Across Join Table with Metadata

筅森魡賤 提交于 2019-12-02 21:12:17
I have 3 entities: [Member] ----OneToMany----> [MemberCategory] ---ManyToOne---> [Category] This works well as far as fetching results from the database, but I can't get the Form Builder to build a correct form controls. I want a list of all categories with checkboxes that are checked for those categories that are used by the member. Eventually I want to add the priority field. Member class Member { protected $id; @ORM\OneToMany(targetEntity="MemberCategory", mappedBy="member") protected $categories; } Category class Category { protected $id; @ORM\Column(name="category_name", type="string",

Twig replaces non-ascii characters with entities

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-02 18:10:01
问题 Well, that's really strange, Twig (I'm using it with Symfony 3) replaces non - ascii characters (for example "ł") with entities (e.g. ł ), but... only in Javascript sections. I have no idea why and how to disable it. Edit: yes, I have UTF-8 everywhere, in Nebeans and in HTML head section. Edit2: here is my current code: {% autoescape false %} <script> $(function(){ alert('ółż'); }) </script> {% endautoescape %} Even with {% autoescape false %} (as suggested by Martin) it still does it. 回答1:

Twig replaces non-ascii characters with entities

做~自己de王妃 提交于 2019-12-02 09:47:48
Well, that's really strange, Twig (I'm using it with Symfony 3) replaces non - ascii characters (for example "ł") with entities (e.g. ł ), but... only in Javascript sections. I have no idea why and how to disable it. Edit: yes, I have UTF-8 everywhere, in Nebeans and in HTML head section. Edit2: here is my current code: {% autoescape false %} <script> $(function(){ alert('ółż'); }) </script> {% endautoescape %} Even with {% autoescape false %} (as suggested by Martin) it still does it. Hi if the caracters are in a variable it's normal, to disabled you can use : {{myvar | raw}} Source if you

Intermediate route optional parameters in Symfony 2

痞子三分冷 提交于 2019-12-02 02:31:29
问题 Problem to solve Is it possible in Symfony 2, define routes with ' intermediate ' optional parameters. I'll use other question data, for supporting me using the same style, for example: localhost /param 1/param 2/param 3/param 4 Example localhost /param 1/param 4 localhost /param 2/param 4 Because I have a problem where none of my parameters should be mandatory, and different logics come into play, subordinated to those activated parameters. Until now if I don't set like this: - localhost

Intermediate route optional parameters in Symfony 2

99封情书 提交于 2019-12-01 23:34:27
Problem to solve Is it possible in Symfony 2, define routes with ' intermediate ' optional parameters. I'll use other question data , for supporting me using the same style, for example: localhost /param 1/param 2/param 3/param 4 Example localhost /param 1/param 4 localhost /param 2/param 4 Because I have a problem where none of my parameters should be mandatory, and different logics come into play, subordinated to those activated parameters. Until now if I don't set like this: - localhost /param 1/param 2/... ( missing: param 3/param 4 ) I can't play with intermediate parameters and it's a

Reference a static template in symfony2

夙愿已清 提交于 2019-12-01 10:30:01
I want to use angular with symfony2. To do so it should be possible to load a template from a reference like this: <div ng-include="/link/to/template.html"></div> The loading is the part of angular. We just have to provide a path to the template. The template should not be rendered with twig. Is this possible with symfony? Simple make a template without twig tags, and a route for it to load via ajax. No controller is required my_template: path: /path/to/template defaults: _controller: FrameworkBundle:Template:template template: 'AcmeBundle:Angular:template.html.twig' More infos: http://symfony

Reference a static template in symfony2

点点圈 提交于 2019-12-01 09:22:32
问题 I want to use angular with symfony2. To do so it should be possible to load a template from a reference like this: <div ng-include="/link/to/template.html"></div> The loading is the part of angular. We just have to provide a path to the template. The template should not be rendered with twig. Is this possible with symfony? 回答1: Simple make a template without twig tags, and a route for it to load via ajax. No controller is required my_template: path: /path/to/template defaults: _controller: