craftcms / craftcms/cms

"Validate related assets" only executed after 2nd Save

Open
#7,112 9 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug
Dominant language
PHP
Stars
3.6k
Forks
705
Avg merge
1d 5h
Merged PRs (30d)
134

Description

Description

In my CP I have a few tabs within a section’s entry fields. In a few of those tabs I only have one asset field. Those asset fields all have the "Validate related assets" option turned on. The individual asset volumes these asset fields refer to have a bunch of fields associated with them (categories, text, etc.) that are partly set to required. If I batch-upload a few assets to one of the fields I can save the entry one time after the image thumbnails appear within the field. Only after trying to save the entry a second time or re-entering it will the assets be marked red and the expected "Couldn't save entry" message appears.

Steps to reproduce
  1. Create asset volume with a few required fields
  2. Create asset field that refers to the volume created and check "Validate related assets" ("Allow uploading directly to the field" is unchecked)
  3. Create entry type and associate field with it in an individual Tab
  4. Go to entry with this entry type and go to the Tab
  5. Choose "Add …" from asset field, throw a few asset files from HD into CP asset window and mark all
  6. Click lower right "Select" button to confirm selection
  7. Image thumbnails appear in the entry field, black type underneath
  8. Click "Save" on entry
  9. Witness entry being saved without error message
  10. Open entry again and go to Tab
  11. Witness all images having red type underneath
  12. Hitting "Save" will throw expected message "Couldn't save entry"
Additional info
  • Craft version: Craft Solo 3.5.15.1
  • PHP version: 7.2
  • Database driver & version: MySQL 5.6.38
  • Plugins & versions: None

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the issue in the Craft CP with an asset volume containing required fields, an asset field with “Validate related assets” enabled, and a tabbed entry type. Trace the asset-selection and entry-save flow; done means the first save after selecting assets validates the related assets and shows “Couldn't save entry” instead of saving invalid content.

Written by the indexing model from the issue text.

Assessment

Tech stack
php
Domain
backend
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.