Skip to content

Fix JForm::load() not replacing form field in same location #129

Closed
wants to merge 1 commit into from

6 participants

@rvsjoen
rvsjoen commented Jul 26, 2011

When loading another form xml definition on a JForm object, and the new xml definition contains field names which overlap, the fields should be replaced in the same location.

In the current implementation, the old field is removed, and then the new field is added to the end of the form, changing the ordering.

This patch fixes the problem with reordering, but I am not sure if it has any other adverse effects, I will leave that up to someone who knows more about the workings of JForm.

@ianmacl
ianmacl commented Jul 27, 2011

1) JFormTest::testLoad
Line:1243 There are 2 original ungrouped fields, 1 replaced and 4 new, resulting in 6 total.
Failed asserting that integer:7 matches expected integer:6.

2) JFormFieldHiddenTest::testGetInput
Line:81 The label of a non-hidden element should be some HTML.
Failed asserting that two strings are equal.
--- Expected
+++ Actual
@@ @@
-foo
+

3) JFormFieldSpacerTest::testGetLabel
Line:101 The getLabel method should return something without error.
Failed asserting that two strings are equal.
--- Expected
+++ Actual
@@ @@
-spacer
+spacer

4) JFormFieldSpacerTest::testGetTitle
Line:101 The getLabel method should return something without error.
Failed asserting that two strings are equal.
--- Expected
+++ Actual
@@ @@
-spacer
+spacer

Tests need to be fixed before this is committed.

@elinw
elinw commented Aug 1, 2011

These tests are failing because when the replacement happens the results in the two fields replaces, which are hidden and spacer, are different than what happens when they are not replaced and therefore the actual and expected do not match. For example the non hidden element in the basic test is replaced with a hidden element which should not return html.

@Hackwar
Joomla! member
Hackwar commented Nov 1, 2011

Stupid question, but how is the original field replaced with your change? Does simpleXML recognize the fields by the name attribute or something? I thought you would have to find the current element and replace that element itself with your new element...

@joomla-jenkins

This pull request could not be tested since the changes could not be cleanly merged.

@elinw
elinw commented Nov 16, 2011

Yes the name attribute.

@chdemko
chdemko commented Feb 22, 2012

@rvsjoen Any news on this (the pull request cannot be merged)?

@ianmacl
ianmacl commented Mar 29, 2012

We'd like to get this in once we have tests and are confident it works correctly.

@ianmacl
ianmacl commented Mar 29, 2012

(and once it has been rebased, etc)

@elinw
elinw commented Mar 29, 2012

Ian Aaron posted a pull request for this.

#1069

@ianmacl
ianmacl commented Mar 29, 2012

Closing in light of [#1069].

@ianmacl ianmacl closed this Mar 29, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.