Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FAPI element type password_confirm wipes out all preset attributes from the form element #6157

Closed
argiepiano opened this issue Jun 20, 2023 · 8 comments · Fixed by backdrop/backdrop#4467

Comments

@argiepiano
Copy link

argiepiano commented Jun 20, 2023

Description of the bug

When creating a form that uses the Form API type password_confirm, all custom #attributes included in the form element definition are removed/ignored.

Steps To Reproduce

To reproduce the behavior:

  1. Create a form callback function that includes a password_confirm element AND contains a custom attribute such as data-important-stuff:
  $form['password'] = array(
    '#type' => 'password_confirm',
    '#title' => 'Password',
    '#maxlength' => 64,
    '#size' => 15,
    '#attributes' => array(
      'data-important-stuff' => 'important-data-goes-here',
    ),
  );
  return $form;
  1. Inspect the rendered output. Notice that the data-important-stuff attribute is not included
Screen Shot 2023-06-20 at 3 01 12 PM

Actual behavior

Custom attributes for the element are removed/not rendered.

Expected behavior

The form element should include the custom attributes.

Additional information

  • Backdrop CMS version: 1.25.1
  • PHP version: 8.1
  • Browser(s) and their versions: Chrome

PR backdrop/backdrop#4467

@argiepiano argiepiano changed the title FAPI password_confim type wipes out al preset attributes of the form element FAPI element type password_confirm wipes out all preset attributes from the form element Jun 20, 2023
@argiepiano
Copy link
Author

PR backdrop/backdrop#4467 ready for review and testing. To test, you can use the example I pasted in the OP.

@argiepiano
Copy link
Author

Test failure in PHP 5 seems unrelated to the PR.

@kiamlaluno
Copy link
Member

It is the test for enabling/disabling modules that fails. I have seen that failure in another PR; it's a random failure which is indeed not related to the PR.

@argiepiano
Copy link
Author

Here's a tiny module to generate that form (for testing).
testing_stuff.zip

@klonos klonos added this to the 1.24.3 milestone Jun 21, 2023
@klonos
Copy link
Member

klonos commented Jun 21, 2023

Tried to close/reopen the PR multiple times in order to get the tests to pass green, however there seems to be an issue with tugboat sandboxes at the moment, and I am also getting the "Start and end date ..." know random failure. I'll try again in later.

Code looks good to me though 👍🏼

@klonos klonos modified the milestones: 1.24.3, 1.25.2 Jun 21, 2023
@indigoxela
Copy link
Member

@argiepiano many thanks for your PR. 🙏 I've left a question there.

@bugfolder
Copy link

Tested (with the provided test module) and confirmed that it works. Closed and reopened the PR, and all tests are running and passing (even though we're getting the Tugboat-over-quota message; presume that tests are running on the old Tugboat instance.) LGTM, WFM.

@quicksketch
Copy link
Member

Thanks @argiepiano, @klonos, @bugfolder, @kiamlaluno, and @indigoxela! I've merged backdrop/backdrop#4467 into 1.x and 1.25.x.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants