Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7430585
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T09:09:54+00:00 2026-05-29T09:09:54+00:00

Okay, so I’m not even sure how to ask this question (much less search

  • 0

Okay, so I’m not even sure how to ask this question (much less search for it). But in my system, I have a variable that forms a relationship for nearly every row. The user does not know it and it is set as a session variable each time a user logs in.

I need this variable to be available to Doctrine. It’s not a default or static, so setting it in the class property isn’t an option. Having it as a hidden form poses a security risk. I’m honestly at a loss. I’ve avoided the problem until I can’t avoid it no more…

It’d accept a workaround for the time being. I really need to get this project launched as soon as humanly possible.

Any help would be greatly appreciated. Even help explaining what I’m trying to accomplish would be appreciated!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-29T09:09:55+00:00Added an answer on May 29, 2026 at 9:09 am

    While this doesn’t resolve my issue entirely, this particular solution may help someone else in a similar predicament…

    In order to inject (I use the term loosely) an object into my form data using a form extension and an event listener.

    Extension:

    <?php
    namespace Acme\DemoBundle\Form\Extension;
    
    use Symfony\Component\Form\AbstractTypeExtension;
    use Symfony\Component\Form\FormBuilder;
    use Symfony\Component\Form\FormEvents;
    use Acme\DemoBundle\Form\EventListener\MyListener;
    
    class FormTypeMyExtension extends AbstractTypeExtension
    {     
      public function getExtendedType()
      {
        return 'form'; // because we're extending the base form, not a specific one
      }
    
    
      public function buildForm(FormBuilder $builder, array $options)
      {
        $listener = new MyListener($this->security, $this->em);
        $builder->addEventListener(FormEvents::SET_DATA, array($listener, 'onSetData'));
      }
    }
    

    Listener:

    <?php
    namespace Acme\DemoBundle\Form\EventListener;
    
    use Symfony\Component\Form\Event\FilterDataEvent;
    use Symfony\Component\Form\FormEvents;
    use Symfony\Component\Security\Core\SecurityContext;
    use Doctrine\ORM\EntityManager;
    
    class MyListener
    {            
      public function onSetData(FilterDataEvent $event)
      {
        // I use form.set_data because it has a method to set data to the form.
    
        $form = $event->getForm();
        $data = $event->getData();
    
        // do things to the form or the data.
      }
    }
    

    (Had some help from this site.)

    That allows you to do anything to the form or form data to every form. Which is how I injected the object initially. My problem is the embedded forms apparently don’t call setData() (presumably because the first object already has the other objects).

    I’ve worked on this all day, so, if my answer is badly worded, complain and I’ll fix it in the morning!

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Okay, I'm pretty sure that this is not possible but a client had asked
Okay, not sure if this is even possible to do locally. I'm using Mac
Okay so im working on this php image upload system but for some reason
Okay so my question is this. Say I have a simple C++ code: #include
Okay, this should be really simple, but I have searched all over for the
Okay, so the answer to my question might not be the problem but here's
Okay, so this probably sounds terribly nefarious, but I need such capabilities for my
Okay, none of the previous questions I have seen with this error seem to
Okay, so this is a long long shot but here it goes... When IE
Okay, I have setup up a handler for a div click but for some

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.