JoomGalleryfriends / JG4-dev

Development repository for JoomGallery v4.x
GNU General Public License v3.0
10 stars 6 forks source link

Add configuration dependent form fields #177

Closed Elfangor93 closed 6 months ago

Elfangor93 commented 6 months ago

This PR adds form fields for configuration params that are inherited through the component global config sets, categories, images, menu items.

The following field types are added:

Adding field to XML form

If you want the global inherited value to be calcultaed and displayed, its important to add the useglobal="true" attribute to the field definition in the XML.

grafik Example of the jgradio field without predefined value for the global option. By default the global option value is an empty string "".

grafik Example of the jgradio field with a predefined value for the global option. This might be useful if you want to show other fields conditionally by the global option value.

Attention! If you want to use this fields in XML forms outside the joomgallery component, for example in a menu item form, its important that the addfieldprefix="Joomgallery\Component\Joomgallery\Administrator\Field" attribute is set in the form or fieldset you will use the field.

How to test this PR

The parameter fields in the image and category form view should work the same as before.

MrMusic commented 6 months ago

An error message appears when saving a category or an image: _Error deriving settings from configurations. Provided context may be wrong. Context: comjoomgallery. But the category or image is saved normally.

MrMusic commented 6 months ago

I tried to include the fields in the menu item for the category view and to display the value from the configuration with Use global. It works quite well. The respective value is displayed 👍 However, the following message always appears when opening the menu entry: Error: Configuration Set not properly loaded. The message is generated here in the DefaultConfig.php file:

//---------Level 3---------
if(isset($this->ids['category']) && $this->ids['category'] > 1)
{
  // Load parent categories
  $cat_model = $this->component->getMVCFactory()->createModel('Category', 'administrator');
  $parents   = $cat_model->getParents($this->ids['category'], true);

  if($parents === false && empty($parents))
  {
    $this->app->enqueueMessage(Text::_('COM_JOOMGALLERY_SERVICE_ERROR_LOAD_CONFIG'), 'error');
    return;
  }
Elfangor93 commented 6 months ago

However, the following message always appears when opening the menu entry:

Should be fixed now...

MrMusic commented 6 months ago

I have tested this item ✅ successfully. Thank you very much.