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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T14:36:46+00:00 2026-06-14T14:36:46+00:00

I need help on using Symfony2.1 forms with method=GET and a clean URL space.

  • 0

I need help on using Symfony2.1 forms with method=GET and a clean URL space.

I am creating a “filter” which I’d like to set in the URL so that people can bookmark their links.

So, very simply the code:

$form = $this->createFormBuilder($defaultData)
    ->add('from', 'date', array('required' => false, 'widget' => 'single_text', 'format' => 'dd.MM.yyyy'))

I render the form widget and all is fine.

However when I submit the form, it produces very ugly GET parameters:

/app_dev.php/de/event?form%5Bfrom%5D=17.11.2012

This is because the input name is of course form[from]

So to clean the URL space, I made myself a theme:

{% block widget_attributes %}
{% spaceless %}
    id="{{ id }}" name="{{ id }}"{% if read_only %} disabled="disabled"{% endif %}{% if required %} required="required"{% endif %}{% if max_length %} maxlength="{{ max_length }}"{% endif %}{% if pattern %} pattern="{{ pattern }}"{% endif %}
    {% for attrname,attrvalue in attr %}{{attrname}}="{{attrvalue}}" {% endfor %}
{% endspaceless %}
{% endblock widget_attributes %}

where I replaced name="{{ full_name }}" with name="{{ id }}".

This works well – my URL space is cleaner:

/app_dev.php/de/event?form_from=17.11.2012

I guess I could live with that – although ideally from=xxx would be better. That is the first and more minor problem.


The second problem is that I can’t get the form to bind anymore – this is obvious because the parameter “form” is no longer set – “form_from” has replaced it, but when you do a bind it is still expecting form[].

I tried to fix that like this:

$fromDate = $this->get('request')->query->get('form_from', null);
$request->query->set('form', array('from' => $fromDate);

But that doesn’t work. I also suspect that I am digging a huge hole of hacks at the moment.

So, the question is: should I just live with the form%5Bfrom%5D url, or is there a better way to do all of this (without using POST obviously)?

  • 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-06-14T14:36:47+00:00Added an answer on June 14, 2026 at 2:36 pm

    You can set the name of the root form to empty, then your field name will be just form. Do so via

    // the first argument to createNamedBuilder() is the name
    $form = $this->get('form.factory')->createNamedBuilder(null, 'form', $defaultData)
        ->add('from', 'date', array(
            'required' => false,
            'widget' => 'single_text',
            'format' => 'dd.MM.yyyy'
        ));
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need help using a UDF in a LINQ which calculates a users position
I need help with using a normal SQL LIKE %% operator within a LINQ
I really need help with using namespaces. How do I get the following code
I need help with using VQmod, if anyone has any experience with, I'd appreciate
I need some help using regex in java. Im trying to achieve 2 different
Possible Duplicate: Regular expression: match all words except I need your help for using
Need help writing a script downloads data from google insight using c# this is
i need help with this. I'am using JQuery's Dynamic Form plug-in, it duplicates my
We are using Linq-to-SQL with stored Procedures we need help on one of our
I need help reading the contents of a webpage. Currently i am using the

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.