symfony-2.4

Symfony2.4 form 'This form should not contain extra fields' error

落花浮王杯 提交于 2019-11-28 11:02:48
I'm trying to build app based on REST api ang AngularJS. I've been following this tutorial http://npmasters.com/2012/11/25/Symfony2-Rest-FOSRestBundle.html but have to change some details ( depreciated methods ) and right now when I post to create new entity I get 'This form should not contain extra fields' error. class MainController extends Controller { public function indexAction(Request $request) { $form = $this->createForm(new TaskType(),null,array('action' => $this->generateUrl('post_tasks').'.json')) ->add('submit','submit'); $note_form = $this->createForm(new NoteType()) ->add('submit'

Inherit form or add type to each form

北城以北 提交于 2019-11-28 00:03:41
问题 I am searching for an easy way to add a bundle of fields to each form. I have found a way to extend the AbstractType and use the buildForm method to add more fields. When creating the form I give the name of my new type (How to Create a Custom Form Field Type). In my opinion it is an easy way, but it is restricted to one type per form. Is there a better way to achieve anything like that? I have read the cookbook of symfony, but I have only found stuff how to extend an existing form not how to

FOSUserBundle Override Roles - Property “roles” in “Acme\DemoBundle\Entity\User” was already declared, but it must be declared only once

房东的猫 提交于 2019-11-27 14:15:54
问题 I like most people are trying to override the FOSUserBundle roles so I can map them ManyToMany to a Role Entity. Unfortunately for some reason due to the mapping of the Model/User I get the following: Property "roles" in "Acme\DemoBundle\Entity\User" was already declared, but it must be declared only once There seems to be some workaround mentioned in this git issue posted in FOSUserBundle: https://github.com/FriendsOfSymfony/FOSUserBundle/pull/1081#issuecomment-19027818 I am Doctrine ORM and