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

use persistent->parameters for setting tag defaults

Hi, I've an ajax search form, (searchable table headers), after having the form submitted, response load results + new search fields. To populate them with the submitted values, I'm using in my controller

$parameters = $query->getParams;
$this->persistent->parameters = $parameters;

$this->tag->setDefault("city",$parameters['bind']["city"] );

and

now if I made a query on city field with caracter "a" as search key, "%a%" is displayed in the input field for city.

Is there a better way to do what I want (and without escaping these %...%)



98.9k
Accepted
answer

You can save the $_POST data instead of the processed criteria parameters:

$this->persistent->parameters = $this->request->getPost();
$this->tag->setDefault("city",$parameters["city"] );


43.9k

Easy ! Thanks phalcon.