Ok, so we got this fix for now..
Somewhere early, ie. in BaseController - initialize(); we are calling this:
/**
* Hopefully, this method won't be needed one day.
* It finds all arrays in request, makes "inline" array representation
* for them and appends it back to request. So elements named like xxx[yyy]
* are prefilled by Phalcon correctly from this moment.
*/
protected function repairRequestForPhalcon() {
$newKeys = array();
$iterator = new \RecursiveIteratorIterator(new \RecursiveArrayIterator($this->request->get()));
foreach ($iterator as $value) {
$newKey = null;
for ($i = 0; $i <= $iterator->getDepth(); $i++) {
if ($i != 0) {
$newKey .= "[" . $iterator->getSubIterator($i)->key() . "]";
} else {
$newKey .= $iterator->getSubIterator($i)->key();
}
}
$newKeys[$newKey] = $value;
}
// Yes, exactly. We are appending new fake keys to actual $_REQUEST,
// so $request->get() will find them there. Phalcon Request object
// doesn't have any public functionality for changing his inner representation;
// or at least we don't know how to do it
$_REQUEST += $newKeys;
}
So the request looks like this now:
array {
_url => "/admin/user/list"
grid => array {
user => array {
filter => array {
text => "someText"
state => "3"
}
}
}
grid[user][filter][text] => "someText"
grid[user][filter][state] => "3"
}
I think Phalcon should understand arrays in request internally, or leave the prefilling for the users completely, otherwise there is a big confusion. Any ideas how to avoid or improve this are very welcomed.