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

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

(cherry picked from commit 38c850c4)
parent 3ef3cfe2
Branches
Tags
28 merge requests!12227Issue #3181946 by jonmcl, mglaman,!12079Issue #3523476 by matthiasm11: Add empty check on operator,!12024Fix: DocBlock comment for return value of Drupal\Core\Database\Connection::transactionManager(),!11974Draft: Issue #3495165 by catch, joeyroth, berdir, texas-bronius: Better warning...,!11934Issue #3520997: DefaultLazyPluginCollection unnecessarily instantiates plugins when sorting collection,!11887Issue #3520065: The migrate Row class API is incomplete,!11636Draft: Issue #3515643 by macsim: fieldNameExists method is inconsistent,!11515Issue #3480419 by mondrake, smustgrave, catch: Method...,!11380Issue #3490698 by catch, spokje: Bump MINIMUM_STABILITY back to 'stable' when...,!11281Use Drupal Core Leadership terminology in MAINTAINERS.txt,!11239Issue #3507548: Allow workspace changes listing to show all items, without a pager,!11238Fix issue #3051797,!11213Issue #3506743 by tomislav.matokovic: Increasing the color contrast for the navigation block title against the background of the navigation sidebar to at least 4.5:1,!11147Draft: Try to avoid manually setting required cache contexts,!11108Issue #3490298 by nicxvan: Profiles can be missed in OOP hooks,!11093Drupal on MongoDB 11.1.x,!11017Issue #3502540: Add date filter for moderated content.,!11009Issue #3486972 migrate feed icon,!10999Cleaning up Taxonomy hooks and updating baseline.,!10977Issue #3501457: Fix path used in a A11y Test Admin,!10881Issue #3489329 by mfb, casey: symfony/http-foundation commit 32310ff breaks PathValidator,!10570Issue #3494197: Convert Twig engine hooks,!10567Issue #3494154: Index is not added if entity doesn't support revisions,!10548Revert "Issue #3478621 by catch, longwave, nicxvan: Add filecache to OOP hook attribute parsing",!10404Margin has been added,!10391Issue #3485117 by nexusnovaz, godotislate, nicxvan: Fix return type on...,!10388Issue #3485117 by nexusnovaz, godotislate, nicxvan: Fix return type on...,!10376Issue #3485117 by nexusnovaz, godotislate, nicxvan: Fix return type on...
Pipeline #351483 canceled
Pipeline: drupal

#351486

    ......@@ -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