Unverified Commit 3ba6bc11 authored by alexpott's avatar alexpott

Issue #3018539 by phenaproxima, rodrigoaguilera, alexpott: Media types cannot...

Issue #3018539 by phenaproxima, rodrigoaguilera, alexpott: Media types cannot be created in the UI without JavaScript
parent 52901b5f
......@@ -304,6 +304,17 @@ function ($item) {
protected function actions(array $form, FormStateInterface $form_state) {
$actions = parent::actions($form, $form_state);
// If the media source has not been chosen yet, turn the submit button into
// a button. This rebuilds the form with the media source's configuration
// form visible, instead of saving the media type. This allows users to
// create a media type without JavaScript enabled. With JavaScript enabled,
// this rebuild occurs during an AJAX request.
// @see \Drupal\media\MediaTypeForm::ajaxHandlerData()
if (empty($this->getEntity()->get('source'))) {
$actions['submit']['#type'] = 'button';
$actions['submit']['#value'] = $this->t('Save');
$actions['delete']['#value'] = $this->t('Delete');
$actions['delete']['#access'] = $this->entity->access('delete');
namespace Drupal\Tests\media\Functional;
use Drupal\media\Entity\MediaType;
* Ensures that media UI works correctly without JavaScript.
* @group media
class MediaTypeCreationTest extends MediaFunctionalTestBase {
* {@inheritdoc}
public static $modules = [
* Tests the media type creation form with only the mandatory options.
public function testMediaTypeCreationForm() {
$machine_name = mb_strtolower($this->randomMachineName());
$this->assertSession()->fieldValueEquals('Test config value', 'This is default value.');
$this->assertInstanceOf(MediaType::class, MediaType::load($machine_name));
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