Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 12 additions & 10 deletions src/View/Helper/DatatableHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -461,11 +461,12 @@ protected function validateConfigurationOptions()
*/
protected function processColumnTypeSearch()
{
$this->setTableTypeSearch($this->getConfig('searchHeadersType'));
if ($this->searchHeadersTypes === null) {
throw new MissConfiguredException(__('Search headers type not configured'));
if ($this->searchHeadersTypes === null || $this->searchHeadersTypes == []) {
$this->searchHeadersTypes = $this->getConfig('searchHeadersTypes');
}
if ($this->searchHeadersTypes === null || $this->searchHeadersTypes == []) {
$this->searchHeadersTypes = $this->fillDefaulTypes(count($this->dataKeys));
}

$rows = [];
foreach ($this->searchHeadersTypes as $definition) {
$parts = [];
Expand Down Expand Up @@ -649,12 +650,12 @@ public function getTableHeaders(
*/
public function setTableTypeSearch(?array $tableSearchHeaders = null): void
{
$defaultTypeSearch = $this->fillDefaulTypes(count($this->dataKeys));
if ($tableSearchHeaders === null) {
$this->searchHeadersTypes = $this->fillDefaulTypes(count($this->dataKeys));
} elseif (count($tableSearchHeaders) != count($this->dataKeys)) {
throw new MissConfiguredException(
__('Number of columns in search headers must be equal to number of columns in searchable columns')
);
$this->searchHeadersTypes = $defaultTypeSearch;
} elseif (count($tableSearchHeaders) !== count($this->dataKeys)) {
$this->searchHeadersTypes = $tableSearchHeaders + $defaultTypeSearch;
ksort($this->searchHeadersTypes);
} else {
$this->searchHeadersTypes = $tableSearchHeaders;
}
Expand All @@ -676,12 +677,13 @@ public function getSearchHedadersTypes()
* @param int $count Number of columns in searchable columns
* @return array
*/
private function fillDefaulTypes(int $count): array
protected function fillDefaulTypes(int $count): array
{
$searchTypes = [];
for ($i = 0; $i < $count; $i++) {
$searchTypes[] = ['type' => 'input', 'data' => []];
}

return $searchTypes;
}
}