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');
No Fatal error.
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
Latest staging
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.
customradio.php
it will work.@mbabker can you check?
Labels |
Added:
?
|
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.
Category | ⇒ | Fields |
Status | New | ⇒ | Confirmed |
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
{
}
Category | Fields | ⇒ | Documentation |
Status | Confirmed | ⇒ | Expected Behaviour |
Closed_Date | 0000-00-00 00:00:00 | ⇒ | 2017-03-17 14:57:31 |
Closed_By | ⇒ | nibra |
Status | Expected Behaviour | ⇒ | Closed |
Closed_Date | 2017-03-17 14:57:31 | ⇒ | 2017-03-17 14:57:32 |
Closed_By | nibra | ⇒ | joomla-cms-bot |
Set to "closed" on behalf of @nibra by The JTracker Application at issues.joomla.org/joomla-cms/13382
Added to documentation:
https://docs.joomla.org/Creating_a_custom_form_field_type
@mbabker can you check this one?