We have moved our forum to GitHub Discussions. For questions about Phalcon v3/v4/v5 you can visit here and for Phalcon v6 here.

Query string includes form submit button value?

When I do a GET request with a form, the submit value shows up in the query string:

my/pretty/url?daterange=2017-05-10+~+2017-06-28&submit=Submit

Not that important, but I would like to get rid of it. How could i do this?

My form initialize method:

public function initialize($entity = null, $user_options = array())
{
    parent::initialize($entity, $user_options);

    $daterange = new Element\Text('daterange');
    $daterange->setAttributes(array(
        'id' => 'daterange',
    ));
    $this->add($daterange);

    $filter = new Element\Submit('filter');
    $filter->setUserOption('icon', 'filter');
    $filter->setAttributes(array(
        'title' => $this->translator->_('filter'),
        'value' => $this->translator->_('filter'),
        'class' => 'btn btn-primary btn-sm'
    ));
    $this->add($filter);
}


3.4k
edited Jun '17

can we see your view ?

If your submit button is an input tag, this is push in get or post values.

https://www.w3schools.com/tags/tag_input.asp

You should use button tag and it should disappear from your querie string.

https://www.w3schools.com/tags/tag_button.asp