public function setModel($model, $display_field = null)
{
if ($model instanceof Model) {
return AbstractObject::setModel($model);
}
$this->model_name = is_string($model) ? $model : get_class($model);
$this->model_name = (string) $this->app->normalizeClassName($this->model_name, 'Model');
if ($display_field) {
$this->display_field = (string) $display_field;
}
if ($display_field !== false) {
$this->owner->addExpression($this->getDereferenced())->set(array($this, 'calculateSubQuery'))->caption((string) $this->caption());
}
$this->system(true);
$this->editable(true);
$this->visible(false);
return $this;
}