Supplying an optional parameter for autocomplete in accordance with the Zend Framework

I have a form with (at least) the following two fields:

  • The country
  • club

A club is a field that is created using the ZendX_JQuery_Form_Element_AutoComplete element , which also generates the following javascript code:

$("#club").autocomplete({"url":"\/mywebsite\/\/mycontroller\/autocomplete"});

I have a database of clubs around the country. I want only clubs to return (for a given country). This list should be retrieved using a remote (ajax) call. Code for this:

 public function autocompleteAction()
    {
        $request = $this->getRequest();

        $filter = $request->getParam('q');
        $country = $request->getParam('country');

        $clublist = getClubListBySubstring($country, $filter);

        $this->_helper->autoComplete($clublist);
    }

Perhaps I can change the above javascript code, bypassing the generation made by ZendX_JQuery_Form_Element_AutoComplete, and add an extra element to the URL, which is interpreted as a country parameter .

? - ExtraParams, ?

+3
1

" ", Javascript . script :

  • jQuery Autocomplete , .
  • .
  • Zend Framework , , .

jQuery , ZendX_JQuery_Form_Element_AutoComplete , . , " ", :

http://www.joelonsoftware.com/articles/LeakyAbstractions.html

( ZF) ZF, , , , .

, , .

+4

Source: https://habr.com/ru/post/1711861/


All Articles