No Code Attached Yet
avatar deepalimad
deepalimad
16 May 2025

Steps to reproduce the issue

  1. In a custom Joomla component, define a field in the admin form like so:

    <fieldset name="modulepositionset" label="Select Module Position"
              addfieldpath="administrator/components/com_modules/models/fields">
        <field name="moduleposition"
               type="moduleposition"
               label="Select Position"
               description="Choose a module position." />
    </fieldset>
  2. Navigate to the admin backend and open the form.

  3. Click the "Select Position" button rendered by the moduleposition field.

  4. Observe the error.


Expected result

  • The modal should open showing the list of available module positions, allowing the user to select one.
  • The field should work outside com_modules, particularly in custom components.

Actual result

  • An error modal appears with the message:
    COM_MODULES_CHANGE_POSITION_BUTTON
    An error has occurred.

  • The URL of the modal includes an invalid or non-existent view:

    index.php?option=com_modules&view=positions&layout=modal&tmpl=component&function=jSelectPosition_
    
  • When you remove &view=positions, the modal loads successfully:

    index.php?option=com_modules&layout=modal&tmpl=component&function=jSelectPosition_
    

System information (as much as possible)

  • Joomla version: 4.x / 5.x (tested on both)
  • PHP version: 8.x
  • Server type: Apache/Nginx (doesn't seem to affect this issue)
  • Browser: Any

Additional comments

  • It appears the moduleposition field is tightly coupled with com_modules, making it unusable in custom components.
  • The error is caused by a broken modal URL pointing to view=positions, which doesn't resolve outside of com_modules.
  • Removing &view=positions from the URL allows the modal to load correctly.
  • Possible solution: make the view optional or adjust the field to handle a fallback if used outside of com_modules.
avatar deepalimad deepalimad - open - 16 May 2025
avatar joomla-cms-bot joomla-cms-bot - change - 16 May 2025
Labels Added: No Code Attached Yet
avatar joomla-cms-bot joomla-cms-bot - labeled - 16 May 2025
avatar AkameOuO
AkameOuO - comment - 16 May 2025

The field type in com_modules is modulesPosition ('modules' in plural and 'P' is uppercase) . If you want to use this one, the field should be defined like this. (Although this still missing language text.)

<fieldset name="modulepositionset" label="Select Module Position"
	addfieldprefix="Joomla\Component\Modules\Administrator\Field">
	<field name="modulesposition"
		type="modulesPosition"
		label="Select Position"
		description="Choose a module position." />
</fieldset>

With this xml, the field will look like:

Image


Also confirmed the issue is happened in Joomla\CMS\Form\Field\ModulepositionField.

Image

Image

avatar brianteeman
brianteeman - comment - 15 Jun 2025

The field should work outside com_modules, particularly in custom components.

Why should a field that you are specifically loading from "administrator/components/com_modules/models/fields" work elsewhere?

Add a Comment

Login with GitHub to post a comment