fix: [CRUD] various issues fixed with the search parameter handling on the index views
parent
a0570d853e
commit
3a16eac89a
|
@ -74,12 +74,12 @@ class CRUDComponent extends Component
|
||||||
$this->Controller->set('entity', $data);
|
$this->Controller->set('entity', $data);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function edit(int $id): void
|
public function edit(int $id, array $params = []): void
|
||||||
{
|
{
|
||||||
if (empty($id)) {
|
if (empty($id)) {
|
||||||
throw new NotFoundException(__('Invalid {0}.', $this->ObjectAlias));
|
throw new NotFoundException(__('Invalid {0}.', $this->ObjectAlias));
|
||||||
}
|
}
|
||||||
$data = $this->Table->get($id);
|
$data = $this->Table->get($id, isset($params['get']) ? $params['get'] : []);
|
||||||
if ($this->request->is(['post', 'put'])) {
|
if ($this->request->is(['post', 'put'])) {
|
||||||
$this->Table->patchEntity($data, $this->request->getData());
|
$this->Table->patchEntity($data, $this->request->getData());
|
||||||
if ($this->Table->save($data)) {
|
if ($this->Table->save($data)) {
|
||||||
|
@ -147,7 +147,7 @@ class CRUDComponent extends Component
|
||||||
];
|
];
|
||||||
if (!empty($params)) {
|
if (!empty($params)) {
|
||||||
foreach ($params as $param => $paramValue) {
|
foreach ($params as $param => $paramValue) {
|
||||||
if (strpos($param, '.') !== null) {
|
if (strpos($param, '.') !== false) {
|
||||||
$param = explode('.', $param);
|
$param = explode('.', $param);
|
||||||
if ($param[0] === $this->Table->getAlias()) {
|
if ($param[0] === $this->Table->getAlias()) {
|
||||||
$massagedFilters['simpleFilters'][implode('.', $param)] = $paramValue;
|
$massagedFilters['simpleFilters'][implode('.', $param)] = $paramValue;
|
||||||
|
@ -155,7 +155,7 @@ class CRUDComponent extends Component
|
||||||
$massagedFilters['relatedFilters'][implode('.', $param)] = $paramValue;
|
$massagedFilters['relatedFilters'][implode('.', $param)] = $paramValue;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
$massagedFilters['simpleFilters'][] = $params;
|
$massagedFilters['simpleFilters'][$param] = $paramValue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -180,6 +180,9 @@ class CRUDComponent extends Component
|
||||||
$conditions = array();
|
$conditions = array();
|
||||||
if (!empty($params['simpleFilters'])) {
|
if (!empty($params['simpleFilters'])) {
|
||||||
foreach ($params['simpleFilters'] as $filter => $filterValue) {
|
foreach ($params['simpleFilters'] as $filter => $filterValue) {
|
||||||
|
if ($filter === 'quickFilter') {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
if (strlen(trim($filterValue, '%')) === strlen($filterValue)) {
|
if (strlen(trim($filterValue, '%')) === strlen($filterValue)) {
|
||||||
$query->where([$filter => $filterValue]);
|
$query->where([$filter => $filterValue]);
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Reference in New Issue