Closed schliflo closed 4 years ago
I've reproduced the issue.
The issue is not fully fixed but goes over the error.
In the mean time, please use this blueprint (updated for the upcoming version):
title: Slides
description: Slides for slideshows
type: flex-objects
# Flex configuration
config:
# Administration Configuration
admin:
# Admin menu
menu:
list:
route: '/slides'
title: Slides
icon: fa-address-card-o
# Authorization to be able to see the menu item
authorize: ['admin.pages', 'admin.super']
# Priority -10 .. 10 (highest goes up)
priority: 2
# Admin template type (folder)
template: default
# List view
list:
# Fields shown in the list view
fields:
header.title:
link: edit
search: true
# Extra options
options:
# Default number of records for pagination
per_page: 20
# Default ordering
order:
by: title
dir: asc
edit:
title:
template: "{{ form.value('header.title') }}"
# Site Configuration
site:
templates:
collection:
# Lookup for the template layout files for collections of objects
paths:
- 'flex/{TYPE}/collection/{LAYOUT}{EXT}'
object:
# Lookup for the template layout files for objects
paths:
- 'flex/{TYPE}/object/{LAYOUT}{EXT}'
defaults:
# Default template {TYPE}; overridden by filename of this blueprint if template folder exists
type: slides
# Default template {LAYOUT}; can be overridden in render calls (usually Twig in templates)
layout: default
# Data Configuration
data:
# Object class to be used, allowing custom methods for the object
object: 'Grav\Common\Flex\Types\Generic\GenericObject'
# Collection class to be used, allowing custom methods for the collections
collection: 'Grav\Common\Flex\Types\Generic\GenericCollection'
# Index class to be used, works as a quick database-like lookup index
index: 'Grav\Common\Flex\Types\Generic\GenericIndex'
storage:
# Storage class, if you want to have associated assets, such like images, use FolderStorage
class: 'Grav\Framework\Flex\Storage\FolderStorage'
options:
formatter:
# File formatter class, in this case the file is stored in markdown
class: 'Grav\Framework\File\Formatter\MarkdownFormatter'
# Folder where all the objects will be stored
folder: 'user-data://slides'
# File pattern to generate the filename
pattern: '{FOLDER}/{KEY}/{FILE}{EXT}'
# Filename
file: slide
# Field which will be used as {KEY}
key: storage_key
# Keep index file in filesystem to speed up lookups
indexed: true
search:
# Search options
options:
contains: 1
# Fields to be searched
fields:
- header.title
# Regular form definition
form:
validation: loose
fields:
header.img:
type: file
label: Slide Image
help: The image used for in the slide
size: full
style: vertical
multiple: false
accept:
- 'image/*'
header.title:
type: text
autofocus: true
style: vertical
label: PLUGIN_ADMIN.TITLE
markdown:
type: markdown
validate:
type: textarea
EDIT: updated to use GenericObject
very cool to see the extra menu items! while this does not completely solve the issue i have, it's a lot better already! thank you for your help. I'm looking forward to the new release :)
I installed the latest version today and am having an issue with the file type. When creating or editing a flex object I choose an image and it saves without any errors or warnings. The file doesn't appear to be uploaded and the image field in the markdown file does not have a value.
I am wondering if the problem I am describing is related to this issue or if I am doing something wrong. I tried using the blueprint provided by @mahagr to make sure it wasn't just an issue with my blueprint.
The issue still persists in RC5 (no error, file does not get saved). Do you think this will get fixed in time for the final release @mahagr ?
Either way I'd suggest closing this issue (labeled bug
) or #37 (labeled enhancement
) -otherwise they seem to be the same.
I am facing this issue too, @mahagr why in your blueprint it's missing the destination option under the header.img field? Just asking. Thanks
Should be fixed. @ricardo118 Can you test it out?
@mahagr using the blueprint above I get
without using a destination, no save happens for the object.
Using a destination like destination: data://slides/images
I get
The object saves with
---
title: title
img: { }
---
slide content
Updated the blueprint again and fixed the bug in Grav. Thanks for testing, now it really works.
Updated the blueprint again and fixed the bug in Grav. Thanks for testing, now it really works.
@mahagr I reckon this will work with the next Release Candidate? I’m on Admin v1.10.0-rc.11 which was released three weeks prior to your comment here.
I copied the above pasted blueprint and everything works except the file upload – no matter whether I added a destination
to the file field definition or not.
@mahagr addressed file uploads in an independent branch of grav. It’s a big change to unify and cleanup the logic and has not been merged yet.
File upload fails with
Undefined index: name
:user/blueprints/flex-objects/slides.yaml
: