joomla-cms icon indicating copy to clipboard operation
joomla-cms copied to clipboard

[4.2] Add Global Setting for Form Layout option to custom fields

Open AndySDH opened this issue 3 years ago • 19 comments

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.

AndySDH avatar Mar 19 '22 15:03 AndySDH

Thanks @brianteeman

AndySDH avatar Mar 19 '22 16:03 AndySDH

Updated PR, please test it now guys, thanks! :)

AndySDH avatar Mar 19 '22 18:03 AndySDH

Can you guys please test this? @brianteeman @laoneo @regularlabs

AndySDH avatar Mar 23 '22 10:03 AndySDH

Can you rebase it to the 4.2-dev branch as it is a new feature?

laoneo avatar Mar 23 '22 10:03 laoneo

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

AndySDH avatar Mar 23 '22 10:03 AndySDH

https://user-images.githubusercontent.com/1296369/159136063-8470361b-9b14-4cd5-9654-d4bb58cd143d.gif

brianteeman avatar Mar 23 '22 10:03 brianteeman

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.

laoneo avatar Mar 23 '22 10:03 laoneo

When I want to create an integer field there are untranslated strings: image

laoneo avatar Mar 28 '22 14:03 laoneo

Thank you for spotting this, sorry, please try now.

AndySDH avatar Mar 28 '22 15:03 AndySDH

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.

laoneo avatar Mar 28 '22 15:03 laoneo

Please test again, thanks guys!

AndySDH avatar Mar 29 '22 08:03 AndySDH

Use Global and Use settings from Plugin have the same value.

form-layout

<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>

Quy avatar Mar 30 '22 15:03 Quy

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.

AndySDH avatar Mar 30 '22 18:03 AndySDH

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

brianteeman avatar Mar 30 '22 18:03 brianteeman

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

AndySDH avatar Mar 30 '22 19:03 AndySDH

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.

Quy avatar Mar 31 '22 14:03 Quy

Thanks for the feedback. I removed useglobal="true" for now.

Please test again! Thanks!

AndySDH avatar Mar 31 '22 16:03 AndySDH

Hey guys, any update on this?

AndySDH avatar Jun 10 '22 11:06 AndySDH

This pull requests has been automatically converted to the PSR-12 coding standard.

joomla-bot avatar Jun 27 '22 21:06 joomla-bot

This pull request has been automatically rebased to 5.0-dev.

HLeithner avatar May 02 '23 16:05 HLeithner

This pull request has been automatically rebased to 5.0-dev.

So I guess this PR is scheduled for Joomla 5?

AndySDH avatar Jun 17 '23 13:06 AndySDH

After applying the patch I get this error: Class "Joomla\Plugin\Fields\Integer\Extension\Integer" not found

crommie avatar Aug 26 '23 11:08 crommie

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.

flo-the-cat avatar Aug 26 '23 11:08 flo-the-cat

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.

oshufx avatar Aug 26 '23 11:08 oshufx

@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.

richard67 avatar Aug 26 '23 11:08 richard67

@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

flo-the-cat avatar Aug 26 '23 12:08 flo-the-cat

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.

richard67 avatar Aug 26 '23 12:08 richard67

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.

crommie avatar Aug 26 '23 13:08 crommie

Thanks for testing! One more test to merge :)

AndySDH avatar Aug 31 '23 20:08 AndySDH

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 :)

AndySDH avatar Sep 10 '23 20:09 AndySDH

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.

ceford avatar Sep 15 '23 13:09 ceford