I have been trying to write a plugin that adds fields to the group admin form.
Unfortunately, it seems to be impossible to do this in Joomla as it stands.
Extending the user admin form is easy and well documented, via the user.onContentPrepareForm
event. Since this event is also triggered by the group admin form, I would expect to be able to do something similar, but it doesn't work.
onContentPrepareForm()
method.com_users.user
or com_users.group
.... something like this:
class plgUserFoobar extends JPlugin
{
protected $baseXML = <<<'eof'
<?xml version="1.0" encoding="utf-8"?>
<form>
<fields name="foo">
<fieldset name="team" label="Foo">
<field name="baz" type="text" label="Baz" />
</fieldset>
</fields>
</form>
eof;
public function onContentPrepareForm($form, $data)
{
$formName = $form->getName();
if ($formName != 'com_users.group' && $formname !='com_users.user') {
return true;
}
$form->load($this->baseXML, false);
}
}
The admin panel forms for managing both users and groups should now have a new tab named 'Foo', comtaining a single text field labelled 'Baz'.
The user form does indeed get the new tab and field, but the group form does not.
Joomla 3.7.0
Looking at the XML that defines the user and group forms, the group form is much simpler in structure; its <fieldset>
element is not even named (and thus cannot be accessed by JForm::getGroup
and similar methods). The user form has several fieldsets with a parent <fields>
element to contain them; this element is not present in the groups form.
The result is that although $form->load()
does work and the new formset/fields are loaded into the form object, the resulting XML structure does not match the initial structure of group form, and the fields are not rendered. I have tried numerous variations of the XML to try to get the structure right, but it doesn't seem to be possible.
Labels |
Added:
?
|
Category | ⇒ | com_plugins |
Status | New | ⇒ | Information Required |
Yes, it is. Nothing has changed as far as I know that would have resolved it. It's fairly easy to verify though.
I had to work around it when I encountered the issue as I needed to complete the project I was working on, so I haven't looked back at it since posting it in May, but my solution is ugly and hacky and I would very much like to replace it with nice simply plugin with a tab in the group admin form if at all possible.
Status | Information Required | ⇒ | Discussion |
Labels |
Added:
J3 Issue
|
Status | Discussion | ⇒ | Closed |
Closed_Date | 0000-00-00 00:00:00 | ⇒ | 2018-08-18 17:10:44 |
Closed_By | ⇒ | wilsonge |
@Spudley is this still a valid issue?