getgrav / grav-plugin-admin

Grav Admin Plugin
http://getgrav.org
MIT License
355 stars 225 forks source link

Blueprint File resort error #1562

Open whollaus opened 5 years ago

whollaus commented 5 years ago

I'm sorry, it's me again. :)

[Latest Admin Version: Grav v1.6.0-beta.7 - Admin v1.9.0-beta.7]

There are two demo sites grafik

I add one file field (Blueprint see below) an upload a file to the Typography Page (the second page) grafik

After that I change the sorting: grafik

After saving, the image is no longer displayed. grafik

-> The path is not automatically adjusted when you re-sort

`extends@: default

form: fields: tabs: fields: content: fields: header.image1: type: file label: Image avoid_overwriting: true destination: '@self' multiple: false style: vertical accept:

rhukster commented 5 years ago

Can you please provide your YAML for the form definition in a code block??

whollaus commented 5 years ago
extends@: default

form:
  fields:
    tabs:
      fields:
        content:
          fields:
            header.image1:
              type: file
              label: Image
              avoid_overwriting: true
              destination: '@self'
              multiple: false
              style: vertical
              accept:
                - image/jpg
                - image/jpeg
whollaus commented 5 years ago

Checked the bug with the latest version (Grav v1.6.0-rc.1 - Admin v1.9.0-rc.1). Does not work yet. I think that's really a big bug. Too big for a final release version :) Please let me know if you need more details. Thank you very much.

mahagr commented 5 years ago

Can you also show us the yaml from the page itself as well as twig file for the page type?

whollaus commented 5 years ago

I have used a fresh installation with the quark theme, only change the default.yaml file from

extends@: default

form:
  fields:
    tabs:
      fields:
        advanced:
          fields:
            columns:
              fields:
                column1:
                   fields:
                     header.body_classes:
                       markdown: true
description: 'Available classes in Quark Theme (space separated):<br />`header-fixed`, `header-animated`, `header-dark`, `header-transparent`, `sticky-footer`'

to

extends@: default

form:
  fields:
    tabs:
      fields:
        content:
          fields:
            header.image1:
              type: file
              label: Image
              avoid_overwriting: true
              destination: '@self'
              multiple: false
              style: vertical
              accept:
                - image/jpg
                - image/jpeg
mahagr commented 5 years ago

This is actually a known bug, which I was going to fix before release.

mahagr commented 5 years ago

@rhukster

Alright, this issue exists also in older versions of Grav -- file field stores the full path which breaks if the page gets moved. There's really no easy way to fix this issue; it can be fixed, but the fix is pretty involved (unless we use Flex).

whollaus commented 5 years ago

Only as an idea: The problem is that a fixed path is saved. Perhaps it would be better to save the destination from the Blueprint only?

path: user/pages/02.test/test.jpg -> path: {{ @self }}/test.jpg

In the frontend, the path must then be replaced by the currently valid one. Would also be possible as an additional function like destination: {{ @self }}/test.jpg.