Allow to change upload formats for managed_file
Problem/motivation
Attributes with type: managed_file have no setting for allowed file extensions. The upload field falls back to core's default list (jpg jpeg gif png txt doc xls pdf ppt pps odt ods odp), so common files for menu links, such as SVG icons, cannot be uploaded.
Proposed resolution
Add an optional extensions key to the attribute definition and pass it to the upload field:
attributes:
data-icon:
type: managed_file
upload_location: 'public://menu-icons'
extensions: 'svg png'$form['options']['attributes'][$attribute]['#upload_validators']['FileExtension'] = [
'extensions' => $info['extensions'],
];!11 uses the file_validate_extensions validator, which core deprecated in 10.2 and removed in 11, so it needs to switch to the FileExtension constraint. Document the new key in docs/usage/field-types.md.
Config schema
Also add upload_location and the new extensions key to _menu_link_attributes.attribute in config/schema/menu_link_attributes.schema.yml (moved from #3590641 (closed)). The default_value type for checkboxes is handled in #3483440.