public function populateViaRequest(Request $request)
    {
        $fields = $this->definition->getEditableFieldNames();
        foreach ($fields as $field) {
            $type = $this->definition->getType($field);
            if ($type === 'file') {
                $file = $request->files->get($field);
                if ($file) {
                    $this->set($field, $file->getClientOriginalName());
                }
            } else if ($type === 'reference') {
                $value = $request->get($field);
                if ($value === '') {
                    $value = null;
                }
                $this->set($field, ['id' => $value]);
            } else if ($type === 'many') {
                $array = $request->get($field, []);
                if (is_array($array)) {
                    $many = array_map(function($id) {
                        return ['id' => $id];
                    }, $array);
                    $this->set($field, $many);
                }
            } else {
                $this->set($field, $request->get($field));
            }
        }
    }