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

Issue #3489915 by phenaproxima: RecipeInputFormTrait forces you to check all checkboxes

parent dc129a55
Branches
Tags
13 merge requests!11197Issue #3506427 by eduardo morales alberti: Remove responsive_image.ajax from hook,!11131[10.4.x-only-DO-NOT-MERGE]: Issue ##2842525 Ajax attached to Views exposed filter form does not trigger callbacks,!10786Issue #3490579 by shalini_jha, mstrelan: Add void return to all views...,!5423Draft: Resolve #3329907 "Test2",!3878Removed unused condition head title for views,!3818Issue #2140179: $entity->original gets stale between updates,!3478Issue #3337882: Deleted menus are not removed from content type config,!3154Fixes #2987987 - CSRF token validation broken on routes with optional parameters.,!2964Issue #2865710 : Dependencies from only one instance of a widget are used in display modes,!2062Issue #3246454: Add weekly granularity to views date sort,!10223132456: Fix issue where views instances are emptied before an ajax request is complete,!617Issue #3043725: Provide a Entity Handler for user cancelation,!579Issue #2230909: Simple decimals fail to pass validation
Pipeline #350787 passed with warnings
Pipeline: drupal

#350814

    Pipeline: drupal

    #350798

      Pipeline: drupal

      #350791

        ......@@ -76,9 +76,12 @@ public function collectValue(string $name, DataDefinitionInterface $definition,
        $element += [
        '#description' => $definition->getDescription(),
        '#default_value' => $default_value,
        '#type' => 'value',
        ];
        // Recipe inputs are always required.
        $element['#required'] = TRUE;
        // Recipe inputs are required by default, unless they are single
        // checkboxes, in which case the `#required` behavior doesn't make
        // a lot of sense because it forces the user to check the box.
        $element['#required'] ??= ($element['#type'] !== 'checkbox');
        NestedArray::setValue($this->form, explode('.', $name, 2), $element);
        // Always return the input elements as a tree.
        ......
        ......@@ -29,15 +29,18 @@ public function testRecipeInputViaForm(): void {
        $this->drupalGet('/form-test/recipe-input');
        $assert_session = $this->assertSession();
        // There should only be one nested input element on the page: the one
        // There should only be two nested input elements on the page: the two
        // defined by the input_test recipe.
        $assert_session->elementsCount('css', 'input[name*="["]', 1);
        $assert_session->elementsCount('css', 'input[name*="["]', 2);
        // The default value and description should be visible.
        $assert_session->fieldValueEquals('input_test[owner]', 'Dries Buytaert');
        $assert_session->pageTextContains('The name of the site owner.');
        // All recipe inputs are required.
        $this->assertSame('checkbox', $assert_session->fieldExists('Allow mischief')->getAttribute('type'));
        // All recipe inputs are required, except for checkboxes, for which that
        // behavior makes no sense.
        $this->submitForm(['input_test[owner]' => ''], 'Apply recipe');
        $assert_session->statusMessageContains("Site owner's name field is required.", 'error');
        $assert_session->statusMessageNotContains('Allow mischief field is required.', 'error');
        // All inputs should be validated with their own constraints.
        $this->submitForm(['input_test[owner]' => 'Hacker Joe'], 'Apply recipe');
        $assert_session->statusMessageContains("I don't think you should be owning sites.", 'error');
        ......
        ......@@ -14,6 +14,15 @@ input:
        default:
        source: value
        value: 'Dries Buytaert'
        break_stuff:
        data_type: boolean
        description: 'Should mischief be allowed on this site? Not recommended.'
        form:
        '#type': checkbox
        '#title': 'Allow mischief'
        default:
        source: value
        value: false
        config:
        actions:
        system.site:
        ......
        0% Loading or .
        You are about to add 0 people to the discussion. Proceed with caution.
        Please register or to comment