Commit bef3c9a8 authored by effulgentsia's avatar effulgentsia

Issue #2988617 by samuel.mortenson, phenaproxima: Creating media with the...

Issue #2988617 by samuel.mortenson, phenaproxima: Creating media with the media library upload is broken for unlimited cardinality follow-up
parent 979164b2
......@@ -127,10 +127,10 @@ public function buildForm(array $form, FormStateInterface $form_state) {
'#description' => $this->t('Upload files here to add new media.'),
'#upload_validators' => $upload_validators,
];
$remaining = $this->getRequest()->query->get('media_library_remaining');
if ($remaining) {
$form['upload']['#multiple'] = $remaining > 1;
$form['upload']['#cardinality'] = $form['upload_help']['#cardinality'] = (int) $remaining;
$remaining = (int) $this->getRequest()->query->get('media_library_remaining');
if ($remaining || $remaining === FieldStorageDefinitionInterface::CARDINALITY_UNLIMITED) {
$form['upload']['#multiple'] = $remaining > 1 || $remaining === FieldStorageDefinitionInterface::CARDINALITY_UNLIMITED;
$form['upload']['#cardinality'] = $form['upload_help']['#cardinality'] = $remaining;
}
}
else {
......
......@@ -356,6 +356,10 @@ public function testWidgetUpload() {
$unlimited_button->click();
$assert_session->assertWaitOnAjaxRequest();
// Multiple uploads should be allowed.
// @todo Add test when https://github.com/minkphp/Mink/issues/358 is closed
$this->assertTrue($assert_session->fieldExists('Upload')->hasAttribute('multiple'));
$page->attachFileToField('Upload', $this->container->get('file_system')->realpath($png_image->uri));
$assert_session->assertWaitOnAjaxRequest();
$page->fillField('Name', 'Unlimited Cardinality Image');
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment