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

Sensitive form widget does not function correctly inside a repeater #1321

Open
jaxwilko opened this issue Feb 28, 2025 · 6 comments · May be fixed by #1329
Open

Sensitive form widget does not function correctly inside a repeater #1321

jaxwilko opened this issue Feb 28, 2025 · 6 comments · May be fixed by #1329
Assignees
Milestone

Comments

@jaxwilko
Copy link
Member

jaxwilko commented Feb 28, 2025

Winter CMS Build

dev-develop

PHP Version

8.3

Database engine

MySQL/MariaDB

Plugins installed

Lots :)

Issue description

When using sensitive in a repeater the value gets replaced by the placeholder on save / on view hidden.

Steps to replicate

Make a form with the following:

fields:
    users:
        type: repeater
        form:
            fields:
                username:
                    label: Username
                    type: text
                    span: auto
                password:
                    label: Password
                    type: sensitive
                    span: auto

Workaround

Use text :(

@LukeTowers LukeTowers added this to the 1.2.8 milestone Feb 28, 2025
@bennothommo
Copy link
Member

Use text :(

This made me laugh harder than it should've 😂. Looking into a fix now.

@LukeTowers
Copy link
Member

@bennothommo it's possibly because of the use of post() in the Repeater FormWidget without processing it through the individual FormWidget's getLoadValue(), probably here:

? post($this->formField->getName())

@mjauvin
Copy link
Member

mjauvin commented Mar 15, 2025

@LukeTowers I replaced the code with this and it resolves the issue:

diff --git a/modules/backend/formwidgets/Repeater.php b/modules/backend/formwidgets/Repeater.php
index 4e834c8c3..c26ec1e0f 100644
--- a/modules/backend/formwidgets/Repeater.php
+++ b/modules/backend/formwidgets/Repeater.php
@@ -258,9 +258,7 @@ protected function processSaveValue($value)
      */
     protected function processItems()
     {
-        $currentValue = ($this->loaded === true)
-            ? post($this->formField->getName())
-            : $this->getLoadValue();
+        $currentValue = $this->getLoadValue();
 
         // Detect when a child widget is trying to run an AJAX handler
         // outside of the form element that contains all the repeater

Do you know why the value needs to be fetched from the post in the current code ?

@mjauvin mjauvin linked a pull request Mar 15, 2025 that will close this issue
@LukeTowers
Copy link
Member

@mjauvin my guess would be for widgets & fields that are using dependsOn, or anything that uses AJAX to populate values, like dropdown options or something.

@mjauvin
Copy link
Member

mjauvin commented Mar 18, 2025

@mjauvin my guess would be for widgets & fields that are using dependsOn, or anything that uses AJAX to populate values, like dropdown options or something.

Any idea on a fix then?

@LukeTowers
Copy link
Member

I'll have to play around with it, hopefully this Wednesday.

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

Successfully merging a pull request may close this issue.

4 participants