Empty Group - Add Record Issue

mseddon

New Member
Hi,
I have been debugging a Fabrik 2.1 site on a Joomla 1.5.21 environment and run into an interesting issue to do with group data.

Current Behaviour
If you create a new form and removed all group records so that the 'No Data' message occurs and then save the form everything behaves correctly.

However when you load the form again the /media/com_fabrik/form.js script is executed which tries to calculate how many elements are under each fabrikSubGroup the script will incorrectly return 1 as fabrik never deletes the first grouped record but only hides it (form.js - line 73). Because it is hidden it should return 0.

When you then try to add a new two new records to the group the first one will be labeled as record id=0 (this never changes) and the second will be the count from above (1) plus the new record (+1) so it will be 2.

The upshot is that when you try validation fabrik throws errors because it is trying to validate records 0 and 1 - one of which does not exist (1).

The code for Fabrik 2.x and 3.x is unchanged so this will affect both versions.

My hack workaround is to add a check (form.js line 74):
Code:
		this.repeatGroupMarkers = $H({});
		this.form.getElements('.fabrikGroup').each(function(group) {
			var id = group.id.replace('group', '');
			var c = group.getElements('.fabrikSubGroup').length;
			
			// hack starts here to make sure grouped records start at the correct value
			if (c > 0) {
				var c = $('fabrik_repeat_group_'+(id)+'_counter').value.toInt();
			}
			this.repeatGroupMarkers.set(id, c);
		}.bind(this));

I hope the developers are able to see this and come up with a better solution.

Cheers,
Mike
 
We are in need of some funding.
More details.

Thank you.

Members online

Back
Top