password and password_confirm children do not pick up #states or #attributes

Created on 4 February 2012, almost 13 years ago
Updated 13 May 2024, 8 months ago

I searched the issue queue but didn't see a duplicate. I apologize if I missed one!

D7 core does not seem to pass down #states or #attributes assigned to a parent password_confirm element, to it's children.
I was trying to turn autocomplete off for the password confirm field and add a state.

$form['password_field']['#pre_render'] = array('my_form_process_password_confirm');

function my_form_process_password_confirm($elements) {
  foreach (element_children($elements) as $element) {
    $elements[$element]['#attributes']['autocomplete'] = 'off';
    $elements[$element]['#states'] = array(
      'visible' => array(
      	':input[name="my_checkbox"]' => array('checked' => TRUE),
      ),
    );
  }

return $elements;
}
๐Ÿ› Bug report
Status

Active

Version

11.0 ๐Ÿ”ฅ

Component
Formย  โ†’

Last updated 3 days ago

Created by

๐Ÿ‡ฌ๐Ÿ‡งUnited Kingdom fenda

Live updates comments and jobs are added and updated live.
  • Needs backport to D7

    After being applied to the 8.x branch, it should be considered for backport to the 7.x branch. Note: This tag should generally remain even after the backport has been written, approved, and committed.

Sign in to follow issues

Merge Requests

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • First commit to issue fork.
  • Merge request !8043support for #states in password_confirm โ†’ (Open) created by sukr_s
  • Pipeline finished with Failed
    8 months ago
    Total: 644s
    #171468
  • Pipeline finished with Success
    8 months ago
    Total: 617s
    #171519
  • Pipeline finished with Success
    8 months ago
    Total: 528s
    #171529
  • Status changed to Needs review 8 months ago
  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia sukr_s
  • Status changed to Needs work 8 months ago
  • ๐Ÿ‡บ๐Ÿ‡ธUnited States smustgrave

    Can we add steps to the issue summary (part of standard issue template) since this is a bug report.

  • Status changed to Needs review 8 months ago
  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia sukr_s

    IS updated.

  • Status changed to Needs work 7 months ago
  • The Needs Review Queue Bot โ†’ tested this issue. It no longer applies to Drupal core. Therefore, this issue status is now "Needs work".

    This does not mean that the patch necessarily needs to be re-rolled or the MR rebased. Read the Issue Summary, the issue tags and the latest discussion here to determine what needs to be done.

    Consult the Drupal Contributor Guide โ†’ to find step-by-step guides for working with issues.

  • Pipeline finished with Success
    7 months ago
    Total: 657s
    #201695
  • Status changed to Needs review 7 months ago
  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia sukr_s
  • Status changed to RTBC 6 months ago
  • ๐Ÿ‡บ๐Ÿ‡ธUnited States smustgrave
    1) Drupal\FunctionalJavascriptTests\Core\Form\JavascriptStatesTest::testJavascriptStates
    Behat\Mink\Exception\ResponseTextException: The text "Enter password" appears in the text of this page, but it should not.
    /builds/issue/drupal-1427838/vendor/behat/mink/src/WebAssert.php:907
    /builds/issue/drupal-1427838/vendor/behat/mink/src/WebAssert.php:312
    /builds/issue/drupal-1427838/core/tests/Drupal/FunctionalJavascriptTests/Core/Form/JavascriptStatesTest.php:234
    /builds/issue/drupal-1427838/core/tests/Drupal/FunctionalJavascriptTests/Core/Form/JavascriptStatesTest.php:67
    FAILURES!
    Tests: 1, Assertions: 92, Failures: 1.
    

    Ran the test-only feature which generated the above, showing the test coverage

    Summary appears to be complete.

    Code review solution seems simple and accomplishes the issue.

    LGTM

  • Status changed to Needs work 6 months ago
  • ๐Ÿ‡ณ๐Ÿ‡ฟNew Zealand quietone

    @sukr_s, thanks for working on an older issue!

    I read the issue summary, comments and the MR. There are no unanswered questions.

    I left a comment in the MR asking for a comment to be changed. The title here needs to be updated because it refers to 'password' but the MR makes no changes to password, only to password_confirm. Both of those should be simple to complete.

  • Pipeline finished with Success
    6 months ago
    Total: 502s
    #234473
  • Status changed to Needs review 6 months ago
  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia sukr_s

    - Changed the title.
    - Couldn't locate the MR comment. Nevertheless added a comment at the place of change.

  • Status changed to RTBC 6 months ago
  • ๐Ÿ‡บ๐Ÿ‡ธUnited States smustgrave

    Going to RTBC because title has been updated.

    @quietone I'm not seeing the comment either did it not save?

  • ๐Ÿ‡ณ๐Ÿ‡ฟNew Zealand quietone

    No, I did not submit my earlier comment. I have done so now.

    @sukr_s, thanks for figuring out what I meant.

  • ๐Ÿ‡ฌ๐Ÿ‡งUnited Kingdom alexpott ๐Ÿ‡ช๐Ÿ‡บ๐ŸŒ

    I discussed this with @tim.plunkett and we agreed that adding another check on render element ID is probably not the best way forward. Instead we could do what the comment says and check if the element accepts input but has no markup. So something like

    $key = (isset($elements['#markup']) && $elements['#markup'] === '' && isset($elements['#input']) && $elements['#input'] === TRUE) ? '#wrapper_attributes' : '#attributes';
    

    This way anything in contrib will be fixed as well. We will need update the docs here to...

  • ๐Ÿ‡บ๐Ÿ‡ธUnited States tim.plunkett Philadelphia
  • Pipeline finished with Failed
    4 months ago
    Total: 523s
    #300589
  • Pipeline finished with Success
    4 months ago
    Total: 542s
    #300619
  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia sukr_s

    updated as per #32

  • ๐Ÿ‡บ๐Ÿ‡ธUnited States smustgrave

    Verified test coverage is still there https://git.drupalcode.org/issue/drupal-1427838/-/jobs/2949098

    Appears feedback from @alexpott and @tim.plunkett has been addressed I believe.

  • ๐Ÿ‡ฌ๐Ÿ‡งUnited Kingdom alexpott ๐Ÿ‡ช๐Ÿ‡บ๐ŸŒ

    Committed and pushed 36b2bfae686 to 11.x and a63415bb33f to 11.0.x and 4ba08a0254e to 10.4.x and 4951a71170f to 10.3.x. Thanks!

    • alexpott โ†’ committed 4951a711 on 10.3.x
      Issue #1427838 by sukr_s, smustgrave, quietone, tim.plunkett, alexpott:...
    • alexpott โ†’ committed 4ba08a02 on 10.4.x
      Issue #1427838 by sukr_s, smustgrave, quietone, tim.plunkett, alexpott:...
    • alexpott โ†’ committed a63415bb on 11.0.x
      Issue #1427838 by sukr_s, smustgrave, quietone, tim.plunkett, alexpott:...
    • alexpott โ†’ committed 36b2bfae on 11.x
      Issue #1427838 by sukr_s, smustgrave, quietone, tim.plunkett, alexpott:...
  • Automatically closed - issue fixed for 2 weeks with no activity.

  • ๐Ÿ‡ฆ๐Ÿ‡ทArgentina cesarmiquel

    Hi! I have the following code that used to work fine but now it breaks after this has been deployed. Basically I have a form with a list of items that look something like this:

    <?php
    $address_list = [];
    foreach($address as $id) {
      $address_list[$id] = [
        '#type' => 'item',
        '#markup' => '...',
        '#states' => [
          'visible' => [
            ':input[id="some_select"]' => ['value' => $id],
          ]
        ]
      ];
    }
    $form['addresses'] = $address_list;
    ?>

    This used to work fine before this patch. When you selected an option in the select it would display one of these items which have information related to the selection. I've identified the issue and have verified that this fix is breaking the previous code but I have no clue why when the data-drupal-states is set in the #attributes it works but not in the `#wrapper_attribtues`. Any help? Is there something wrong with the way I'm using the #states? Heelp๐Ÿ™

  • ๐Ÿ‡ฌ๐Ÿ‡งUnited Kingdom steven jones

    @cesarmiquel yeah, I have that exact issue. The logic that was changed in this issue is incorrect. I've raised ๐Ÿ› States are processed and added to the wrong attribute since #1427838 Active to discuss and fix that.

  • ๐Ÿ‡ฆ๐Ÿ‡ทArgentina cesarmiquel

    Thanks @steven-jones for your feedback. I will follow this new issue then. Do you know of a workaround for this to work in the meantime?

  • ๐Ÿ‡ฌ๐Ÿ‡งUnited Kingdom steven jones

    @cesarmiquel you can apply the changes from the MR in ๐Ÿ› States are processed and added to the wrong attribute since #1427838 Active :)

  • ๐Ÿ‡ฆ๐Ÿ‡ทArgentina cesarmiquel

    @steven-jones unfortunately not easily because the site is a multi-site Drupal and I don't have the ability to patch the Drupal Core. I might be able to request a patch but it will take a while (probably a week or maye more **if** they approve it) for them to patch it so I need to find a work around.

Production build 0.71.5 2024