1
0
mirror of https://github.com/processwire/processwire.git synced 2025-08-12 01:34:31 +02:00

Add PR #190 - FieldtypeMulti: orderby sort only if schema supports it

Co-authored-by: pine3ree <pine3ree@gmail.com>
This commit is contained in:
Ryan Cramer
2021-06-01 09:41:05 -04:00
parent 3fe499899b
commit 73b82462fc

View File

@@ -454,7 +454,8 @@ abstract class FieldtypeMulti extends Fieldtype {
$database = $this->wire('database'); $database = $this->wire('database');
$table = $database->escapeTable($field->table); $table = $database->escapeTable($field->table);
$schema = $this->trimDatabaseSchema($this->getDatabaseSchema($field)); $schemaAll = $this->getDatabaseSchema($field);
$schema = $this->trimDatabaseSchema($schemaAll);
$fieldName = $database->escapeCol($field->name); $fieldName = $database->escapeCol($field->name);
$sanitizer = $this->wire('sanitizer'); $sanitizer = $this->wire('sanitizer');
$orderByCols = array(); $orderByCols = array();
@@ -521,7 +522,7 @@ abstract class FieldtypeMulti extends Fieldtype {
if(empty($orderByCols)) { if(empty($orderByCols)) {
// if there are no orderByCols defined, pagination & sorting not supported // if there are no orderByCols defined, pagination & sorting not supported
// default sort for FieldtypeMulti fields is by column 'sort' // default sort for FieldtypeMulti fields is by column 'sort'
$query->orderby("$table.sort"); if(isset($schemaAll['sort'])) $query->orderby("$table.sort");
} else { } else {
// one or more orderByCols is defined, enabling sorting and potential pagination // one or more orderByCols is defined, enabling sorting and potential pagination