Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ValidationResult::addError() doesn't show up anywhere in the UI #967

Closed
robbieaverill opened this issue Jul 16, 2019 · 5 comments
Closed

Comments

@robbieaverill
Copy link
Contributor

robbieaverill commented Jul 16, 2019

Version: 4.4.x-dev

Steps to reproduce

Add this to Image:

    public function validate()
    {
        $validation = parent::validate();
        if ($this->isInDB() && empty($this->Title)) {
            $validation->addError('Testing error');
        }
        return $validation;
    }

Upload an image. This is successful (as expected) because the isInDB() check skips validation.

Open the image and remove the title, then try to save the image.

Expected result

The image should not save. I should see "Testing error" somewhere in an error alert.

Result

The image doesn't save (correct). No validation error is shown in the UI (bug).


This works with $validation->addFieldError('Title', 'Testing error'):

image

PRs

@blueo
Copy link
Contributor

blueo commented May 27, 2021

Just ran into something similar - seems to related to the changes here: #1138 . In my case the validation message isn't showing on an uploaded file thumbnail.

@blueo
Copy link
Contributor

blueo commented May 27, 2021

So it appears since 4.6 validation errors that are not attached to a field will not be displayed anywhere. As per the above description the Edit form will not display anything from addError but now we also don't get a validation message in the Thumbnail view:
eg with the following validation code on Image:

$result->addError('The image already exists (' . $location . ')');

before 4.6 the thumbnail displays the validation error:
image

after 4.6 the thumbnail has a generic error:
image

I feel we need to find a home/better way of displaying these general errors in the admin

blueo added a commit to blueo/silverstripe-asset-admin that referenced this issue Aug 8, 2023
blueo added a commit to blueo/silverstripe-asset-admin that referenced this issue Aug 8, 2023
@blueo
Copy link
Contributor

blueo commented Aug 22, 2023

@emteknetnz FYI I think there is still an outstanding issue when 'addError' is called on an existing asset - so its only partially closed... @GuySartorelli has some context

@GuySartorelli
Copy link
Member

Reopening this. As per the note in the issue description, this has only been resolved for new files, but is still a problem for existing files.

@GuySartorelli
Copy link
Member

Fixed in silverstripe/silverstripe-admin#1587.
This will be automatically tagged by GitHub Actions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants