Skip to content
Snippets Groups Projects
Commit c281ef5a authored by Alex Pott's avatar Alex Pott
Browse files

Issue #2322377 by slashrsm | roald.umandal: Fixed No validation for default image.

parent 0aaa1c80
No related branches found
No related tags found
2 merge requests!7452Issue #1797438. HTML5 validation is preventing form submit and not fully...,!789Issue #3210310: Adjust Database API to remove deprecated Drupal 9 code in Drupal 10
......@@ -350,6 +350,7 @@ protected function defaultImageForm(array &$element, array $settings) {
'#default_value' => empty($settings['default_image']['fid']) ? array() : array($settings['default_image']['fid']),
'#upload_location' => $settings['uri_scheme'] . '://default_images/',
'#element_validate' => array('file_managed_file_validate', array(get_class($this), 'validateDefaultImageForm')),
'#upload_validators' => $this->getUploadValidators(),
);
$element['default_image']['alt'] = array(
'#type' => 'textfield',
......
......@@ -278,6 +278,10 @@ public function testDefaultImages() {
array('@fid' => $default_images['instance2']->id())
)
);
$non_image = $this->drupalGetTestFiles('text');
$this->drupalPostForm(NULL, array('files[instance_settings_default_image_fid]' => drupal_realpath($non_image[0]->uri)), t("Upload"));
$this->assertText(t('The specified file text-0.txt could not be uploaded. Only files with the following extensions are allowed: png gif jpg jpeg.'), 'Non-image file cannot be used as default image.');
}
/**
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment