getgrav / getgrav/grav-plugin-admin

Validation of required upload field causes Runtime Error

Open
#1,939 1 comment 0 reactions 0 assignees View on GitHub
bug
Dominant language
PHP
Stars
377
Forks
225
Avg merge
11h 51m
Merged PRs (30d)
4

Description

Grav v1.6.26 - Admin v1.9.15

When I set filepicker, date or also other fields in blueprint with `validate.required: true` and leave them empty in the admin panel is causes a Runtime Error after hitting the save button:

![image](https://user-images.githubusercontent.com/64414721/89283527-98a50980-d64d-11ea-9615-746f7dbff953.png)

But in this case the file "text.html.twig" exists despite the error claims otherwise. Setting `validate.required: false` makes the error disappear. This error exists only appears on modular pages.

Relevant blueprint code:
``` yaml
header.img:
type: filepicker
label: Logo
preview_images: true
accept:
- .jpg
- .png
validate:
required: true
```

Contributor guide

Open the contributing guide

Research direction

Reproduce the admin save on a modular page using the shown blueprint with validate.required: true, leaving the filepicker empty, and compare it with required: false. Start by tracing validation for modular-page blueprints and the reported reference to text.html.twig; done means an empty required upload shows a validation message instead of a Runtime Error.

Written by the indexing model from the issue text.

Assessment

Tech stack
php
Domain
backend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.