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

Subform duplicated when Saved if subform had (child) subform too #35721

Closed
DelPoint opened this issue Oct 2, 2021 · 4 comments
Closed

Subform duplicated when Saved if subform had (child) subform too #35721

DelPoint opened this issue Oct 2, 2021 · 4 comments

Comments

@DelPoint
Copy link
Contributor

DelPoint commented Oct 2, 2021

Note: the problem can be reproduced only if a template has subforms in its templateDetails.xml, and you try to modify/save template parameters. So, I've provided a very minimalistic template (no front-end fancyness) to demonstrate the issue. Use that for testing.

Steps to reproduce the issue

  1. Install vanilla J! 4.03 (stable) w/o demo data.
  2. Install template test attached: test.zip
  3. Go to System -> Site Template Styles -> test - Default style to change template's parameters.
  4. Switch to Advanced tab/panel.
  5. Add a (parent) subform by clicking the green '+' (plus) button next to the parameter I have Problems.
  6. Add a (child) subform by clicking the green '+' button next to the parameter Child Subform
  7. You should see ONE (parent) subform with ONE (child) subform on your screen - see expected result.
  8. Now click on the Save button to save the template parameters.
  9. After saved, and page refreshed, you will see that the parent subform is duplicated w/o a (child) subform, and also the subform w/ subform (created by the user) is on the screen - see actual result below.

Expected result

Expected Result

Actual result

Actual Result

System information (as much as possible)

Apche 2.4.46
PHP 8.03
MySQL 5.6.17
Joomla! 4.03

Additional comments

  1. Duplicated (parent) subform also saved into the MySQL database.
  2. If we change the user actions a bit:
  • add the 1st (parent) subform AND click Save BEFORE adding the 2nd (child) subform
  • THEN now add the child subform
  • AND now click Save again -> no duplicated subforms will be created
    That suggests maybe this is an error caused by Save: duplicated entries got pushed into the DB, and after page refreshed, DB sent back 2 subforms. Didn't have time for more debugging though.
  1. I also noticed that J! built-in field editor doesn't produce this kind of error. So, I've seen the problem only around the editing of template parameters.
  2. And a final observation: duplicated subform is always inserted BEFORE the subform created by the user, and never after it.
@nozaro33
Copy link

nozaro33 commented Oct 2, 2021

I've also replicated this problem with Joomla 4.0.3, used inside a config.xml

@Fedik
Copy link
Member

Fedik commented Oct 2, 2021

I can confirm,
it worked in past somehow :)

@Fedik
Copy link
Member

Fedik commented Oct 2, 2021

please test #35726

@Fedik Fedik closed this as completed Oct 2, 2021
@DelPoint
Copy link
Contributor Author

DelPoint commented Oct 2, 2021

Hi Fedik,

I can confirm that #35726 solves the duplication of subforms when saved, but it breaks showon functionality now.

Add a second field to the (child) subform with showon condition, which refers to the 1st field of this (child) subform. Condition: showon="first_field!:" (ie. if 1st field empty, 2nd field shouldn't appear).
Using your commit/modifications, as soon as I've added the 2nd (child) subform, ALL fields appeared in this form, ignoring the showon condition of the 2nd field.
Attached a modified test_2 template, where I've added a 2nd field into the (child) subform with showon condition.
Test your commit with this XML now, you'll see what I've described above.
test_2.zip

Also noticed: if a field with showon condition displayed while it shouldn't, and this field is a radio button group (the fancy one), then these buttons are not clickable. I guess, this is a side effect of JS implementation of "showon".

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

No branches or pull requests

4 participants