?
avatar gaelicwinter
gaelicwinter
27 Feb 2020

A recent change to the reference counting in the javascript controlling subforms causes J3.9.15 to not properly save nested subforms. A form rendered from saved data shows blank fields as the data can not properly be read. Rendered subforms with data saved under J3.9.14 is incorrectly displayed.

###Steps to reproduce:

Install Joomla 3.9.14
Modify the file j3914/plugins/actionlog/joomla/joomla.xml to include the following configuration fields:

<config>
	<fields name="params">
		<fieldset name="basic">
			<field name="items"
				   type="subform"
				   label="Items"
				   multiple="true"
			>
				<form name="itemform">
					<field name="itemtext"
						   type="text"
						   label="Item Text"
					/>
					<field name="subitems"
						   type="subform"
						   label="Subitems"
						   multiple="true"
					>
						<form name="subitemform">
							<field name="subitemtext"
								   type="text"
								   label="Subitem Text"
							/>
						</form>
					</field>
				</form>
			</field>
		</fieldset>
	</fields>
</config>

Set the fields in the plugin config page to something like this:

	Items	
		Item text	-> Textvalue
		
		Subitems	-> 
						Subitem Text -> subitemtextvalue

Save the configuration.
From your debugger, see that the POSTed data looks like this:

jform
	params	
		items
			items0
				itemtext = "Textvalue"
				subitems
					subitems0
						subitemtext = "subitemtextvalue"

From phpmyadmin, see that the saved params json data looks like this:

{"items":{"items0":{"itemtext":"Textvalue","subitems":{"subitems0":{"subitemtext":"subitemtextvalue"}}}}}

Compare this to J3.9.15:
Install Joomla 3.9.15
Modify the file j3915/plugins/actionlog/joomla/joomla.xml to include the following configuration fields, same as 3.9.14.

<config>
	<fields name="params">
		<fieldset name="basic">
			<field name="items"
				   type="subform"
				   label="Items"
				   multiple="true"
			>
				<form name="itemform">
					<field name="itemtext"
						   type="text"
						   label="Item Text"
					/>
					<field name="subitems"
						   type="subform"
						   label="Subitems"
						   multiple="true"
					>
						<form name="subitemform">
							<field name="subitemtext"
								   type="text"
								   label="Subitem Text"
							/>
						</form>
					</field>
				</form>
			</field>
		</fieldset>
	</fields>
</config>

Set the fields in the plugin config page to something like this, same as 3.9.14.

	Items	
		Item text	-> Textvalue
		
		Subitems	-> 
						Subitem Text -> subitemtextvalue

Save the configuration.
From your debugger, see that the POSTed data looks like this, different from 3.9.14:

jform
	params	
		items
			items0
				itemtext = "Textvalue"
				subitems = ""
			items1
				subitems
					subitems0
						subitemtext = "subitemtextvalue"

From phpmyadmin, see that the J3.9.15 saved params json data looks like this, different from 3.9.14:

{"items":{"items0":{"itemtext":"Textvalue","subitems":[]},"items1":{"subitems":{"subitems0":{"subitemtext":"subitemtextvalue"}}}}}

For comparison, the J3.9.14 params data was:

{"items":{"items0":{"itemtext":"Textvalue","subitems":{"subitems0":{"subitemtext":"subitemtextvalue"}}}}}
avatar gaelicwinter gaelicwinter - open - 27 Feb 2020
avatar joomla-cms-bot joomla-cms-bot - change - 27 Feb 2020
Labels Added: ?
avatar joomla-cms-bot joomla-cms-bot - labeled - 27 Feb 2020
avatar gaelicwinter
gaelicwinter - comment - 27 Feb 2020

After save on J3.9.14
subform-j3-9-14

After save on J3.9.15
subform-j3-9-15

avatar gaelicwinter
gaelicwinter - comment - 27 Feb 2020

Replacing subform-repeatable.js and subform-repeatable-uncompressed.js in J3.9.15 with the copies from J3.9.14 resolves the issue.

avatar richard67
richard67 - comment - 27 Feb 2020

The only change after 3.9.14 which I can see in history of the 2 JS files is PR #27334 . @Fedik could you check this issue here? Thanks in advance.

avatar Fedik
Fedik - comment - 27 Feb 2020

Replacing subform-repeatable.js and subform-repeatable-uncompressed.js in J3.9.15 with the copies from J3.9.14 resolves the issue.

it not resolve the issue, it replaces one bug to another ?

avatar Fedik
Fedik - comment - 27 Feb 2020

yeah, there a problem in the calculation of a names for a nested inputs

avatar richard67
richard67 - comment - 27 Feb 2020

@Fedik Do you think you can fix that?

avatar Fedik
Fedik - comment - 27 Feb 2020

need time to investigate, it will be not soon

avatar HLeithner
HLeithner - comment - 27 Feb 2020

@Fedik I would like to build 3.9.16-rc next Tuesday do you think you have a fix until this day? Would be great ;-)

avatar Fedik
Fedik - comment - 27 Feb 2020

I can try, but cannot promise

avatar jwaisner jwaisner - change - 27 Feb 2020
Status New Confirmed
avatar gaelicwinter
gaelicwinter - comment - 27 Feb 2020

I really appreciate your efforts. I have two sites I will keep patched manually for the time being. I tried to come up with a workaround in php in the onContentNormaliseRequestData event but it seems like such a hack, and requires a lot of input array manipulation. If there's anything I can do to help please let me know.

avatar Fedik
Fedik - comment - 29 Feb 2020

@gaelicwinter Untill it will be fixed you can use next workaround:

  • create first level items - save
  • create items for nested level - save
avatar Fedik
Fedik - comment - 29 Feb 2020

please test #28134

avatar richard67
richard67 - comment - 29 Feb 2020

Closing as having PR. Please test #28134 .

avatar richard67 richard67 - change - 29 Feb 2020
Status Confirmed Closed
Closed_Date 0000-00-00 00:00:00 2020-02-29 15:16:02
Closed_By richard67
avatar richard67 richard67 - close - 29 Feb 2020

Add a Comment

Login with GitHub to post a comment