Improve efficiency of List widget, empty relations now no longer try to load themselves and show empty JSON array "[]"

This commit is contained in:
Sam Georges 2014-06-29 09:12:11 +10:00
parent 1e168553ab
commit a8371264dc
1 changed files with 10 additions and 1 deletions

View File

@ -549,7 +549,16 @@ class Lists extends WidgetBase
*/
public function getColumnValue($record, $column)
{
$value = $record->{$column->columnName};
/*
* If the column is a relation, it will be a custom select,
* so prevent the Model from attempting to load the relation
* if the value is NULL.
*/
$columnName = $column->columnName;
if ($record->hasRelation($columnName) && array_key_exists($columnName, $record->attributes))
$value = $record->attributes[$columnName];
else
$value = $record->{$columnName};
if (method_exists($this, 'eval'. studly_case($column->type) .'TypeValue'))
$value = $this->{'eval'. studly_case($column->type) .'TypeValue'}($value, $column);