?
avatar andrepereiradasilva
andrepereiradasilva
27 Dec 2016

Steps to reproduce the issue

Cannot load a custom field if we have an field with the same filename.

Add this to isis index.php

// Create the extended radio form class file and add that fields path to JFormHelper.
JFolder::create(JPATH_ROOT . '/testfields');
JFile::write(JPATH_ROOT . '/testfields/radio.php', '<?php JFormHelper::loadFieldClass(\'radio\'); class TestFormFieldRadio extends JFormFieldRadio { } ?>');
JFormHelper::addFieldPath(JPATH_ROOT . '/testfields');

// Load the radio field.
JFormHelper::loadFieldClass('radio');

Expected result

No Fatal error.

Actual result

3.6.5: All seems fine
3.7.0: Fatal error: Class 'JFormFieldRadio' not found in /path/to/joomla-staging/testfields/radio.php on line 1

System information (as much as possible)

Latest staging

Additional comments

  1. With the previous code before this change #12060, ie, require_once $file; instead of JLoader::register($class, $file); in this line https://github.com/joomla/joomla-cms/blob/staging/libraries/joomla/form/helper.php#L215 there is no fatal error.

But not sure this is the root problem.

  1. This seems to only happens when the extended field filename is the same as the original field (ex: both are called radio.php). If the same filename is called customradio.php it will work.

@mbabker can you check?

avatar andrepereiradasilva andrepereiradasilva - open - 27 Dec 2016
avatar joomla-cms-bot joomla-cms-bot - change - 27 Dec 2016
Labels Added: ?
avatar joomla-cms-bot joomla-cms-bot - labeled - 27 Dec 2016
avatar andrepereiradasilva andrepereiradasilva - change - 27 Dec 2016
The description was changed
avatar andrepereiradasilva andrepereiradasilva - edited - 27 Dec 2016
avatar andrepereiradasilva andrepereiradasilva - edited - 27 Dec 2016
avatar andrepereiradasilva andrepereiradasilva - change - 27 Dec 2016
The description was changed
avatar andrepereiradasilva andrepereiradasilva - edited - 27 Dec 2016
avatar andrepereiradasilva
andrepereiradasilva - comment - 30 Dec 2016

@mbabker can you check this one?

avatar mbabker
mbabker - comment - 5 Jan 2017

In all honesty, what you're running into is in part the lack of autoloading of the form fields. But I don't know what else to look for here, so go for the quick win and revert that change and be done with it. I don't have much time to dig deeper.

Honestly, for that specific condition, a call to JFormHelper::loadFieldClass('radio'); should result in JFormFieldRadio being loaded from libraries/joomla/form/fields/radio.php and JFormHelper::loadFieldClass('test.radio'); should load JPATH_ROOT . '/testfields/radio.php but good luck figuring that out.

avatar nibra nibra - change - 17 Mar 2017
Category Fields
avatar nibra nibra - change - 17 Mar 2017
Status New Confirmed
avatar nibra
nibra - comment - 17 Mar 2017

Since the form fields do not work with JLoader (due to the folder name being form/fields instead of form/field), the JForm field class must be loaded manually, if (and only then) the filename of a field in any additional field path matches the filename of core field. In the case from this issue, the field class should look like

<?php
require_once JPATH_LIBRARIES . '/joomla/form/fields/radio.php';

class TestFormFieldRadio extends JFormFieldRadio
{

}

This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/13382.
avatar nibra nibra - change - 17 Mar 2017
Category Fields Documentation
avatar nibra nibra - change - 17 Mar 2017
Status Confirmed Expected Behaviour
Closed_Date 0000-00-00 00:00:00 2017-03-17 14:57:31
Closed_By nibra
avatar joomla-cms-bot joomla-cms-bot - change - 17 Mar 2017
Status Expected Behaviour Closed
Closed_Date 2017-03-17 14:57:31 2017-03-17 14:57:32
Closed_By nibra joomla-cms-bot
avatar joomla-cms-bot joomla-cms-bot - close - 17 Mar 2017
avatar joomla-cms-bot
joomla-cms-bot - comment - 17 Mar 2017

Set to "closed" on behalf of @nibra by The JTracker Application at issues.joomla.org/joomla-cms/13382

avatar nibra
nibra - comment - 17 Mar 2017

Add a Comment

Login with GitHub to post a comment