1

I am trying to update a very nice Joomla 3 plugin to Joomla 4 because the plugin creator did not update it himself. Upgrade is almost ok except that if no default value is set for one of the parameters, the plugin crashes. It does work ok if I define a default value prior to activating the plugin...

Below (excerpt) is the parameter which requires a default value in the xml file:

<fieldset name="basic">
    <field name="mailto_admins" type="usergrouplist" default="0"
        multiple="true"
        label="PLG_MAILTO_ADMINS_LABEL"
        description="PLG_MAILTO_ADMINS_DESC">
    </field>
           .....

How can I set a default value to the mailto_admins field name so that it sets it to superusers (usergroup id 8 if I'm right)? Setting default=8 in the field definition does not seem to do it.

Thank you!

1 Answer 1

1

The code as posted works however there is not enough detail in the original xml posted to see the elements that wrap around it which is where I believe the issue is.

I have tested this and it works as I believe the OP expects it should.

<config>
    <fields name="params">
        <fieldset name="basic">
            <field name="mailto_admins"
                   type="usergrouplist" default="8"
                   multiple="true"
                   label="PLG_MAILTO_ADMINS_LABEL"
                   description="PLG_MAILTO_ADMINS_DESC">
            </field>
        </fieldset>
    </fields>
</config>

In my testing I found that not having the <fields> element or not specifying name="params" had varying outcomes with whether the default was set in the params field of the #__extension table or saved when changed.

        <fields name="params">
....
        </fields>
4
  • Hello,Thx for the reply.
    – Phil91
    Commented Mar 22, 2023 at 9:30
  • Hello,Thx for the reply. I did completely wrap the fields as you indicated. I just did not want to display the entire list here. The complete <config> section is wrapped correctly. Issue is just that Superusers are not set as default in the usergrouplist field although I defaulted the field value to 8...
    – Phil91
    Commented Mar 22, 2023 at 9:37
  • In a Joomla 4.8 environment that I installed the plugin it on I could see the entry in the #__extensions table with the value of 8 and when I opened the Plugin the SuperUser was the only entry selected/highlighted. Are you not seeing that?
    – Irata
    Commented Mar 22, 2023 at 10:49
  • OK. Now I got it to work, although no changes occurred. I just uninstalled and reinstalled the zip. Thanks for helping out!
    – Phil91
    Commented Mar 22, 2023 at 14:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.