I have a form created using Zend_Form, with the = GET method used to search for records with elements, as shown below:
[form] username [input type = "text" name = "uname"] [input type = "submit" value = "Search" name = "search"] [/ Form]
After submitting the form, all GET parameters along with the submit button value appear in the URL.
http://mysite.com/users/search?uname=abc&search=Search
How to avoid submit button value appearing in url? Is routing a routine?
, , ( ) .
:
$params = $this->getRequest()->getParams(); if isset($params['search']) unset($params['search']); return $this->_helper->Redirector->setGotoSimple('thisAction', null, null, $params); handle form here
, Post/Redirect/Get, , ( ) , , - ( Wiki- ).
, . IMO -.
, name,
$submit = new Zend_Form_Element_Submit('search')->setAttrib('name', '');
a Zend_Form
Zend_Form
// Input element $submit = $this->createElement('submit', 'search')->setAttrib('name', ''); // Or Button element $submit = $this->createElement('button', 'search')->setAttribs(array ( 'name' => '', 'type' => 'submit', );
, GET/POST.
, , GET, , , . , , "submit", , .
Zend_View_Helper_FormSubmit, , submit . , "submit" .
Zend_View_Helper_FormSubmit
$element->setAttribs( array('helper' => 'My_Helper_FormSubmit') );
Then create your own form element class and remove the name attribute from the element using preg_replace. Its beauty lies in the fact that it will not interfere with other decorators.
So something like this:
class My_Button extends Zend_Form_Element_Submit { public function render() { return preg_replace('/(<input.*?)( name="[^"]*")([^>]*>)/', "$1$3", parent::render(), 1); } }
You can remove the name attribute for the submit button in javascript. JQuery example:
$('input[name="submit"]').removeAttr('name');
Source: https://habr.com/ru/post/1764105/More articles:Distributed low latency cache for Java & C ++ Object - javaHow to preload all default tabs using jQuery - jqueryProblem with istream :: tellg ()? - c ++wpf validation - how can I get this code to initiate validation when typing (cf when exiting a field) - c #How to show a white popup on a custom Google map? - javascriptMissing XML end while serializing with DataContractSerializer - c #How to improve accuracy on the Eigenface algorithm - opencvdjango deleted row ΡΡΡΠ΅ΡΡΠ²ΡΠ΅Ρ? - djangoWho can create libssh2.a for the iPhone? - iphoneHow long should connectionString timeout in ASP.NET applications? (SqlClient) - sql-serverAll Articles