public function importFields($model, $fields = null)
    {
        $this->model = $model;

        if ($fields === false) {
            return;
        }

        if (!$fields) {
            if ($model->only_fields) {
                $fields = $model->only_fields;
            } else {
                $fields = [];
                // get all field-elements
                foreach ($model->elements as $field => $f_object) {
                    if ($f_object instanceof \atk4\data\Field) {
                        $fields[] = $f_object;
                    }
                }
            }
        }

        if (!is_array($fields)) {
            $fields = [$fields];
        }

        // import fields one by one
        foreach ($fields as $field) {
            $this->importField($field);
        }

        return $this;
    }
public function importFields($model, $fields = null)
    {
        $this->model = $model;

        if ($fields === false) {
            return;
        }

        if (!$fields) {
            if ($model->only_fields) {
                $fields = $model->only_fields;
            } else {
                $fields = [];
                // get all field-elements
                foreach ($model->elements as $field => $f_object) {
                    if ($f_object instanceof \atk4\data\Field) {
                        $fields[] = $f_object;
                    }
                }
            }
        }

        if (!is_array($fields)) {
            $fields = [$fields];
        }

        // import fields one by one
        foreach ($fields as $field) {
            $this->importField($field);
        }

        return $this;
    }
public function importFields ( $ model , $ fields = null ) { $ this -> model = $ model ; if ( $ fields === false ) { return ; } if ( ! $ fields ) { if ( $ model -> only_fields ) { $ fields = $ model -> only_fields ; } else { $ fields = [ ] ; // get all field-elements foreach ( $ model -> elements as $ field => $ f_object ) { if ( $ f_object instanceof \ atk4 \ data \ Field ) { $ fields [ ] = $ f_object ; } } } } if ( ! is_array ( $ fields ) ) { $ fields = [ $ fields ] ; } // import fields one by one foreach ( $ fields as $ field ) { $ this -> importField ( $ field ) ; } return $ this ; }
Import model fields in view.

Use $fields === false if you want to associate view with model, but don't fill view fields.

@param \atk4\data\Model $model
@param array|string|bool $fields

@return void|$this
Import model fields in view .