Hi,

I have started to build a search function on my website..

My idea was to have a filter form class, give it an object which i
then will serialize and then save it in a session.. and it works just
perfect if i have no relationships in the object..

But when i want to make a relation to an another table, that
relationship will not be serialized.. can some one help? Is it
possible, or do i have to do it in an another way, here is what i do:

  public function filterAction()
  {
    $filter = new \Club\UserBundle\Entity\User();

    $form = $this->createForm(new \Club\UserBundle\Filter\User($filter));
    $form->bindRequest($this->get('request'));

    if ($form->isValid()) {
      
$this->get('session')->set('filter.admin_user',serialize($form->getData()));
    }

    return $this->forward('ClubUserBundle:AdminUser:index');
  }

Pretty straight forward, and when i want to load the form i simple
does unserialize the object and load it with setData()..

  public function indexAction()
  {
    $em = $this->get('doctrine')->getEntityManager();

    $filter = unserialize($this->get('session')->get('filter.admin_user'));
    $filter = ($filter instanceOf \Club\UserBundle\Entity\User) ?
$filter : new \Club\UserBundle\Entity\User();

    $filter_form = $this->createForm(new \Club\UserBundle\Filter\User());
    $filter_form->setData($filter);

Can someone give me a hint, or maybe have a better solution for
creating search functionality?

Best regards,
Michael Holm

-- 
If you want to report a vulnerability issue on symfony, please send it to 
security at symfony-project.com

You received this message because you are subscribed to the Google
Groups "symfony users" group.
To post to this group, send email to symfony-users@googlegroups.com
To unsubscribe from this group, send email to
symfony-users+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/symfony-users?hl=en

Reply via email to