Controller_MVCGrid::importField PHP Method

importField() public method

Import one field from model into grid.
public importField ( string $field ) : void | Grid | Controller_Grid_Format
$field string
return void | Grid | Controller_Grid_Format
    public function importField($field)
    {
        $field = $this->model->hasElement($field);
        if (!$field) {
            return;
        }
        /** @type Field $field */
        $field_name = $field->short_name;
        if ($field instanceof Field_Reference) {
            $field_name = $field->getDereferenced();
        }
        $field_type = $this->getFieldType($field);
        /** @type string $field_caption */
        $field_caption = $field->caption();
        $this->field_associations[$field_name] = $field;
        $column = $this->owner->addColumn($field_type, $field_name, $field_caption);
        if ($field->sortable() && $column->hasMethod('makeSortable')) {
            $column->makeSortable();
        }
        return $column;
    }