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 7562553
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T13:26:09+00:00 2026-05-30T13:26:09+00:00

I created a filter form to limit the entities shown in a list. It

  • 0

I created a filter form to limit the entities shown in a list.
It works by POST, and I need it to remember the state, so when you leva the page and return later the filters ara the same than when you left.

I stored the filters in the session and load them when no POST is used. The filters work great.
But the form does not display the values. I am triing to update the request values before binding the form but this isn’t working, I don’t know why…

$filterForm = $this->createForm(new TourFilter($this->container, $destinations));
$session = $this->getRequest()->getSession();

if ($request->getMethod() == 'POST') {
  //This is when I get the request (POST) values to do the filtering

  $filterForm->bindRequest($request);
  $params = $request->request->get('buv_marketplacebundle_tourfilter');

  //in parseFilerParams I do some validation and transforming parameters
  $filters = $this->parseFilterParams($params, $base_filters);

  //store current params in the session
  $session->set('tour_filters', $params);

} else {
  //get parameters from the session
  $params = $session->get('tour_filters');

  if (is_array($params) && count($params) > 0) {
    //update the request with the parameters from the session
    $request->request->replace(array('buv_marketplacebundle_tourfilter' => $params));

    //bind the updated request to the form
    $filterForm->bindRequest($request);

    $filters = $this->parseFilterParams($params, $base_filters);
  } else {
    $filters = $base_filters;
  }
}

//search for the entities
$entities = $em->getRepository('BuvMarketplaceBundle:Tour')->getFilteredTours($filters);
  • 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-30T13:26:10+00:00Added an answer on May 30, 2026 at 1:26 pm

    The form->bindRequest() method is for populating a form’s underlying data class with data from the request. When you call it from the else clause you are binding the form to a request which contains no data, effectively clearing the form. To manually fill the form you need to call form->setData(). Then assuming you are passing your $filterForm in your call to render() (I can’t see the whole of your action method) your filter params should be populated.

    For example, assuming TourFilter is the data class for your filter form, instead of:

    //bind the updated request to the form
    $filterForm->bindRequest($request);
    

    You need something like:

    // This line can go at the top, use $filterData in the second line
    $filterData = new TourFilter($this->container, $destinations);
    ...
    $filterData->setParams($params);
    $filterForm->setData($filterData);
    

    This may not be exactly right as I don’t know the name of the TourFilter attribute that maps to your form’s params field.

    If you are not going to use $form->getData() to get values from your form (in this case ‘params’) you don’t need to call form->bindRequest() at all. This is generally useful where the form’s underlying data class is an entity and saves manually coping values over from the form before persisting the entity to the DB. For example:

    $filterForm->bindRequest($request);
    $filterData = $filterForm->getData();
    $params = $filterData->getParams();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have created a Django app. I have a registration page(simple HTML form) in
I'm trying to create a form filter, that would do some post-processing of a
I have a DirectShow filter created with Delphi Pro 6 and the DSPACK direct
I've created a search with a couple of comboboxes that allow users to filter
How to create Photoshop Stamp filter analog in any pixel shading language? (I need
I recently created a Sinatra app with a login form (no basic auth). To
I've created a custom lookup form in Axapta 3.0 in which a user can
I am having problem in django. I have created a form in my app
I've got this complex filtering mechanism... d = copy(request.GET) d.setdefault('sort_by', 'created') d.setdefault('sort_dir', 'desc') form
I have a large file, so I have created a filter for removing invalid

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.