Skip to content
Grav 2.0 is officially stable. Read the announcement →

Community guidelines

Please keep discussions civil and on-topic. Repeated violations may lead to a temporary ban.

Forms & Blueprints

Site.yaml with image

Started by Mick 8 years ago · 2 replies · 1112 views
8 years ago

Hello !

In the gateway theme, i have got in the site.yaml :
header:
title: 'The beautiful title'
background: thebackground.jpg

in order to make it easily "customisable" , i have added in the user/blueprints/config a site.yaml with :
@extends:
'@parent'

form:
fields:
anothersection:
type: section
title: Mapajo
underline: true

YAML
        fields:
            header.title:
                type: text
                label: A label
                size: large

            header.background:
                type: file
                label: My background                    
                destination: 'user/themes/mapajo/img'
                multiple: false
                accept:
                - image/*   

The form is working :
image|690x230

when i saved i got a strange message :
Twig_Error_Runtime
The merge filter only works with arrays or "Traversable", got "string" as first argument.

if i open the site.yaml, i get :
header:
title: 'Natura4ever - Votre distributeur'
background:
0: hero-bg.jpg
user/themes/mapajo/img/31sq6-Fond_Herbe.jpg:
name: 31sq6-Fond_Herbe.jpg
type: image/jpeg
size: 109786
path: user/themes/mapajo/img/31sq6-Fond_Herbe.jpg

if someone have the solution ....

Thanks

7 years ago

Did you get a solution to this, I'm getting this too.

7 years ago

I had the same problem, I wanted to do the same as you. For anyone that comes across this issue: you probably added hero-bg.jpg manually in your yaml to test the configuration option? When you proceed to upload a file through the admin, it will be added as the second element because there your first item is already there. Grav adds a "0: " in front but doesn't know what to do with it; it's not a valid file upload. So simply removing that dummy setting worked for me!

Suggested topics

Topic Participants Replies Views Activity
Forms & Blueprints · by Ton Haarmans, 5 years ago
13 1138 4 months ago
Forms & Blueprints · by Hugo Oliveira, 5 months ago
0 61 5 months ago
Forms & Blueprints · by Flachy Joe, 6 months ago
9 135 6 months ago
Forms & Blueprints · by Augustus, 7 months ago
7 110 7 months ago
Forms & Blueprints · by Julien, 7 months ago
10 129 7 months ago