symfony-2.3

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

三世轮回 提交于 2019-12-09 05:46:08
问题 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 ); }

CAS Authentication Symfony2

做~自己de王妃 提交于 2019-12-09 05:34:42
问题 I'm looking for a bundle to integrate CAS authentication on Symfony 2.3. I found these options and the truth is I'm not convinced any, since almost all bundles seem to be abandoned without updating. 1.- sensiolabs / CasBundle: https://github.com/sensiolabs/CasBundle The documentation is sparse and incomplete. I have not found any examples of how to use it. 2.- BeSimple / BeSimpleSsoAuthBundle: https://github.com/BeSimple/BeSimpleSsoAuthBundle With this I'm testing and I am having some

Symfony 2.3 FOSUserBundle does not find security.context

£可爱£侵袭症+ 提交于 2019-12-08 11:42:24
问题 I installed the FOS Bundle like mentioned in: https://github.com/FriendsOfSymfony/FOSUserBundle/blob/master/Resources/doc/index.md After installation with composer and setting up the user class i always get: [Symfony\Component\DependencyInjection\Exception\ServiceNotFoundException] The service "fos_user.security.login_manager" has a dependency on a non-exi stent service "security.context". I checked the existence of the path and there is the contextinterface that is included in the

Symfony2-Doctrine2 inheritance persist not working properly

那年仲夏 提交于 2019-12-07 21:05:23
问题 I have a project in Symfony 2.3, using Doctrine ORM 2.3.4, and I'm using class inheritance: a parent class /** * @ORM\Entity * @ORM\Table(name="parent") * @ORM\InheritanceType("JOINED") * @ORM\DiscriminatorColumn(name="discr", type="string") * @ORM\DiscriminatorMap({"child"="Child"}) */ class Parent { /** * @ORM\Column(name="id", type="integer") * @ORM\Id * @ORM\GeneratedValue(strategy="AUTO") */ private $id; public function getId() { return $this->id; } // other fields & methods } and a

How to add an Event Listener to a dynamically added field using Symfony Forms

我的梦境 提交于 2019-12-07 20:25:20
问题 I am using event listeners to dynamically modify a form. I want to add another event listener to a field that was added dynamically. Im not sure how to accomplish this. public function buildForm(FormBuilderInterface $builder, array $options) { $builder->add('first_field','choice',array( 'choices'=>array('1'=>'First Choice','2'=>'Second Choice') )); $builder->addEventListener(FormEvents::PRE_SET_DATA, array($this, 'preSetData')); $builder->get('first_field')->addEventListener(FormEvents::POST

Access to debug (profiler) information before redirection in Symfony

笑着哭i 提交于 2019-12-07 15:20:43
问题 After submitting a form I usually redirect a user to another page (other than the form itself). Therefore I lose the Profile (debug information, like log). I mean after clicking the Debug Toolbar I get information about the request after redirection. But I do know Symfony keeps information about the previous page. I mean it doesn't forget it. Is there a way to access this information? Where is the debug info about the request before redirection? 回答1: When you open the Profiler, there is a

Form CollectionType with radio buttons fails after Symfony 2.7 upgrade

我的未来我决定 提交于 2019-12-07 07:23:27
Getting below error.. An exception has been thrown during the rendering of a template ("The form's view data is expected to be of type scalar, array or an instance of \ArrayAccess, but is an instance of class Proxies__CG__\BLA\MyBundle\Entity\TransportType. You can avoid this error by setting the "data_class" option to "Proxies__CG__\BLA\MyBundle\Entity\TransportType" or by adding a view transformer that transforms an instance of class Proxies__CG__\BLA\MyBundle\Entity\TransportType to scalar, array or an instance of \ArrayAccess.") in MyBundle:Shipping:form.html.twig at line 8. $builder->add(

How to add an Event Listener to a dynamically added field using Symfony Forms

三世轮回 提交于 2019-12-06 04:50:41
I am using event listeners to dynamically modify a form. I want to add another event listener to a field that was added dynamically. Im not sure how to accomplish this. public function buildForm(FormBuilderInterface $builder, array $options) { $builder->add('first_field','choice',array( 'choices'=>array('1'=>'First Choice','2'=>'Second Choice') )); $builder->addEventListener(FormEvents::PRE_SET_DATA, array($this, 'preSetData')); $builder->get('first_field')->addEventListener(FormEvents::POST_SUBMIT, array($this, 'postSubmit')); } public function preSetData(FormEvent $event) { $form = $event-

Disabling some checkboxes of choice widget in buildForm()

折月煮酒 提交于 2019-12-06 04:45:10
I have a form widget of type "choice" which is being displayed as a list of many checkboxes. Everything works great. So to stress it out: there is ONE widget, with MANY checkboxes (and NOT several checkbox widgets). Now, I want to disable some of those checkboxes. The data for that is avaliable in the $options-Array. Here is the buildForm()-function of my FooType.php ... public function buildForm(FormBuilderInterface $builder, array $options) { $builder ->add('foo', 'choice', array('choices' => $options['choiceArray']['id'], 'multiple' => true, 'expanded' => true, 'disabled' => $options[

Symfony2 How to get the selected value from a select field with twig

☆樱花仙子☆ 提交于 2019-12-06 03:43:09
I have a form that has some bootstrap nav-tabs and I need to repeat in every nav-tabs some info that I have preloaded from a select type field. I can access to the Id with {{ dump(form.proveedor.vars.value) }} But I need the selected label value. How can I do this? Hopefully I get you question correctly. {% set label = '' %} {% for choice in form.proveedor.vars.choices %} {% if choice.value == form.proveedor.vars.value %} {% set label = choice.label %} {% endif %} {% endfor %} {{ label }} selected is an attribute, so you can access it with: {{ dump(form.proveedor.vars.attr["selected"]) }} Then