joomla-cms
joomla-cms copied to clipboard
[4.2] Add Global Setting for Form Layout option to custom fields
Pull Request for Issue #37162. Follow-up to PR #36551 and issue #36548.
Purpose of the PR
As discussed in #37162, this allows users to set a global preference for the HTML Select for custom fields of types: list, SQL, radio, integer.
I would have just removed the option, as the "raw" select is just ugly, but @laoneo noted that we need to keep it for Backwards Compatibility.
Summary of Changes
- Added plugin settings for all relevant fields so that the field inherits from the global options by default (this allows users to set a global preference instead of having to set it for each field they create)
- The global option will still use the old "raw" style by default (to keep Backwards Compatibility)
- Moved the field setting in the correct place (fieldparams instead of params) to be consistent with past implementations
- Implemented the same setting for the Integer field type as well (it was forgotten about in PR 36551 )
- Renamed the option to "Form Layout" for it to be more explicative
- Added new language strings in a shared language file to avoid duplicating them for all field types
Testing Instructions
- Create a list custom field where 'Multiple' is set to 'Yes'
- Keep the 'Form Layout' as 'Use Settings from Plugin'
- Go to Plugin Manager, and in the plugin options of 'Fields - List', change the default 'Form Layout' option
- Edit an article and check the form display of the field
Actual result BEFORE applying this Pull Request
There was no global setting to inherit from the plugin for 'Form Layout'
Expected result AFTER applying this Pull Request
There is now a global setting for 'Form Layout' that controls the default value when not specified in an individual field.
Changing the global setting will change the form layout of the field.
Thanks @brianteeman
Updated PR, please test it now guys, thanks! :)
Can you guys please test this? @brianteeman @laoneo @regularlabs
Can you rebase it to the 4.2-dev branch as it is a new feature?
Done, I was able to do it! @laoneo Thanks to the docs haha: https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/proposing-changes-to-your-work-with-pull-requests/changing-the-base-branch-of-a-pull-request
https://user-images.githubusercontent.com/1296369/159136063-8470361b-9b14-4cd5-9654-d4bb58cd143d.gif
When the next time the branch is merged from 4.1-dev into 4.2-dev, then the commits which are not from you will disappear.
When I want to create an integer field there are untranslated strings:

Thank you for spotting this, sorry, please try now.
I have tested this item :white_check_mark: successfully on 9137eee3df49ab57d87d772f810afd922d71dc0a
This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/37320.
Please test again, thanks guys!
Use Global and Use settings from Plugin have the same value.

<select id="jform_fieldparams_form_layout" name="jform[fieldparams][form_layout]" class="form-select form-select">
<option value="" selected="selected">Use Global</option>
<option value="" selected="selected">Use settings from Plugin</option>
<option value="joomla.form.field.list">HTML Select</option>
<option value="joomla.form.field.list-fancy-select">Enhanced Select</option>
</select>
Thanks for spotting this @Quy, I guess this was due to @brianteeman suggestion of adding useglobal="true".
What is the standard practice here? Should we remove the useglobal="true" attribute, or should we remove <option value="">COM_FIELDS_FIELD_USE_GLOBAL</option> ?
I see that, for comparison, the 'multiple' field is not using useglobal="true" as an attribute.
useglobal = true should result in the select showing something like "Use Gobal (HTML Select)" which you cannot see when you have it as an option
That's interesting. Though It doesn't seem to happen from @Quy screen for some reason it seems, @Quy can you confirm?
If it works that way, we should probably also do an additional PR to cover other cases where useglobal="true" is not yet used (it doesn't seem to be implemented everywhere, maybe not for field plugins) @brianteeman
It does not display as seen in the screenshot. I would say do a separate PR for useglobal and not include it in this PR if it is available in plugins.
Thanks for the feedback. I removed useglobal="true" for now.
Please test again! Thanks!
Hey guys, any update on this?
This pull requests has been automatically converted to the PSR-12 coding standard.
This pull request has been automatically rebased to 5.0-dev.
This pull request has been automatically rebased to 5.0-dev.
So I guess this PR is scheduled for Joomla 5?
After applying the patch I get this error: Class "Joomla\Plugin\Fields\Integer\Extension\Integer" not found
I have tested this item :red_circle: unsuccessfully on 9137eee3df49ab57d87d772f810afd922d71dc0a
Althought the patch does indeed add the required field, you cannot then use ti as adding an article is broken with the following message
Class "Joomla\Plugin\Fields\Integer\Extension\Integer" not found
Reverting the patch and you can add articles again
This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/37320.
I have tested this item :red_circle: unsuccessfully on 9137eee3df49ab57d87d772f810afd922d71dc0a
This test was unsuccessful due to articles no longer being able to be created after the patch had been applied. This is the error that returned.
An error has occurred. 0 Class "Joomla\Plugin\Fields\Integer\Extension\Integer" not found
This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/37320.
@crommie @flo-the-cat @oshufx The reason for the unsuccessful tests is because this PR has merge conflicts. You can see them when going to the PR and scroll to the bottom. I will try to solve them.
@crommie @flo-the-cat @oshufx The reason for the unsuccessful tests is because this PR has merge conflicts. You can see them when going to the PR and scroll to the bottom. I will try to solve them.
Just say when and we will retest
Just say when and we will retest
@crommie @flo-the-cat @oshufx Ready. If you use Patchtester, just don't forget to revert this and any other PRs and then fetching the list of PRs again before applying this PR again.
I have tested this item :white_check_mark: successfully on 9137eee3df49ab57d87d772f810afd922d71dc0a
Without patch:
Form layout (in options tab) has options Default and Enhanced Select Plugin has option to enable/disable Multiple and add a Default Value for the list
With patch:
Form layout is now in the first tab and no longer in the options tab. It has options Use settings from plugin, HTML Select and Enhanced Select Plugin has option to enable/disable Multiple, add a Default Value for the list and a dropdown to choose HTML Select or Enhanced Select
This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/37320.
Thanks for testing! One more test to merge :)
On second thoughts, I decided to undo the change of moving the form_layout setting from params to fieldparmas. For multiple reasons:
- For backwards compatibility. Moving it to fieldparams would mean saved values would have been lost
- It's under params for the subform, and the option is named the same. So it's best if it's consistent across all field types.
- It's a setting shared by multiple fields, so it makes more sense to be in the Form Options
So the option has now returned once again under "Options -> Form Options", as part of the standard params.
Please re-test again, thank you :)
I am afraid the test instruction are not clear enough for me to follow:
Go to Plugin Manager, and in the plugin options of 'Fields - List', change the default 'Form Layout' option
Change it to what? I have a choice of HTML Select or Enhanced Select. I created some list values here too - but that does not seem right and they are not used.
Edit an article and check the form display of the field
I get either an empty list box or an empty textarea. I don't know what I am looking for.
Testing in 5.0.0-beta2-dev
This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/37320.