Make WordPress Core

Opened 3 years ago

Last modified 12 months ago

#54438 new enhancement

"Required fields are marked" shows up without required fields being present

Reported by: webzunft's profile webzunft Owned by:
Milestone: Awaiting Review Priority: normal
Severity: minor Version: 5.8.2
Component: Media Keywords: required-fields needs-patch
Focuses: ui Cc:

Description

A support ticket for my Image Source Control (ISC) plugin made me investigate this.

https://wordpress.org/support/topic/erforderliche-felder-sind-mit-markiert/

Whenever a custom field is added to the attachment edit page, the notice "Required fields are marked" is displayed by WordPress core.

ISC uses the attachment_fields_to_edit filter for that.

I looked into wp-admin/includes/media.php. The code responsible for showing the message is

if ( $item ) {
		$item = '<p class="media-types media-types-required-info">' .
			/* translators: %s: Asterisk symbol (*). */
			sprintf( __( 'Required fields are marked %s' ), '<span class="required">*</span>' ) .
			'</p>' .
			'<table class="compat-attachment-fields">' . $item . '</table>';
	}

The foreach loop that goes through all fields could easily check if any field has the "required" attribute and rather use that as a condition to show the message instead of $item.

Change History (4)

#1 @sabernhardt
3 years ago

  • Component changed from General to Media
  • Keywords required-fields needs-patch added

Thanks for the report!

That code is in the get_compat_media_markup function. The if ( $item ) condition is necessary to determine whether to output the table tag (which lacks role="presentation"), but another condition could be added inside that one for the required field message.

#2 @sabernhardt
3 years ago

And get_media_item probably should have something similar, though that function adds the required field message before the foreach loop.

(wp_media_insert_url_form has the message, too, but that always includes required fields)

#3 @archon810
14 months ago

Any updates on resolving this one please? Just ran into the same issue and found this ticket.

This ticket was mentioned in Slack in #core by svunz. View the logs.


12 months ago

Note: See TracTickets for help on using tickets.