Joomla-cms: JForm B/C broken

Created on 12 May 2017  路  6Comments  路  Source: joomla/joomla-cms

Steps to reproduce the issue

Having a form defined like this:

<?xml version="1.0" encoding="utf-8"?>
<form>
    <fields name="custom_fields" />
</form>

Note: I've only added the fields section to explain how this issue happens. custom_fields is just an empty fields section there to allow field injection.

Before you could do this to add a field to a form fields section:

        $xml = '<field type="text" name="test-field" label="Test field" />';

        $form->setField(new \simpleXmlElement($xml), 'custom_fields');

And retrieve the field like:

$field = $form->getField('test-field', 'custom_fields');

Which was returning the correct field.

After this:
https://github.com/joomla/joomla-cms/pull/14737

It looks like we are now forcing that a fieldset exists on the fields section:

//fields[@name="custom_fields"]/fieldset[@name="default"]

because the new $fieldset param added to the function:
https://github.com/joomla/joomla-cms/pull/14737/files#diff-ed54af5d39d21ed9a84d28eba903bd5fR1082

So the field is never return.

Expected result

I'd expect B/C. So if fieldset was not required before now it shouldn't. Before this XML worked:

<fields name="custom_fields">
        <!-- fields here -->
</fields>

Actual result

Now fieldset is mandatory so you need an structure like:

<fields name="custom_fields">
    <fieldset name="default">
        <!-- fields here -->
    </fieldset>
</fields>

System information (as much as possible)

Joomla v3.7.0

Additional comments

See https://github.com/joomla/joomla-cms/pull/14737

No Code Attached Yet

Most helpful comment

$fieldset should maybe have a null value but probably that removes the sense of adding such parameter?

Ping me when I'm banned so I can start being a hero on twitter 馃拑

All 6 comments

No. I didn't test v3.7.0. I know I should be banned from the project for not doing so and everything since Windows Me is my fault. Let's skip that part. TY.

@rdeutz since that was your PR, can you have a look?

@Bakual will have a look but first I need to process the ban for roberto :-)

$fieldset should maybe have a null value but probably that removes the sense of adding such parameter?

Ping me when I'm banned so I can start being a hero on twitter 馃拑

isformbrokenbyrobertdeutz

closed because we have a PR #15981 to test

Was this page helpful?
0 / 5 - 0 ratings

Related issues

uglyeoin picture uglyeoin  路  5Comments

alex7r picture alex7r  路  4Comments

Hils picture Hils  路  5Comments

Didldu-Florian picture Didldu-Florian  路  4Comments

brianteeman picture brianteeman  路  5Comments