Advertisement

How to get article form instance in admin panel?

Need help with the Administration of your Joomla! 3.x site? This is the spot for you.

Moderator: General Support Moderators

Forum rules
Forum Rules
Absolute Beginner's Guide to Joomla! <-- please read before posting, this means YOU.
Forum Post Assistant - If you are serious about wanting help, you will use this tool to help you post.
Windows Defender SmartScreen Issues <-- please read this if using Windows 10.
Post Reply
voron121
Joomla! Fledgling
Joomla! Fledgling
Posts: 4
Joined: Mon Oct 31, 2022 6:27 pm

How to get article form instance in admin panel?

Post by voron121 » Fri Jun 21, 2024 11:49 am

Hi!

I try to create some plugin which should add one additional option into article edite form (right panel, in main tab with text editor).

If I undestood right, we can took an object Joomla\CMS\Form\Form use some event from plugin and put any additional fields into them.

My question is: how to get instance of current form with all data and params for article edite page in plugin ?

Advertisement
User avatar
Per Yngve Berg
Joomla! Master
Joomla! Master
Posts: 31156
Joined: Mon Oct 27, 2008 9:27 pm
Location: Romerike, Norway

Re: How to get article form instance in admin panel?

Post by Per Yngve Berg » Fri Jun 21, 2024 12:20 pm

Can't you do it with Custom Fields?

voron121
Joomla! Fledgling
Joomla! Fledgling
Posts: 4
Joined: Mon Oct 31, 2022 6:27 pm

Re: How to get article form instance in admin panel?

Post by voron121 » Fri Jun 21, 2024 2:39 pm

Per Yngve Berg wrote: Fri Jun 21, 2024 12:20 pm Can't you do it with Custom Fields?
Technicaly speaking: yes.
But my goal is group some ammount of additionl fields into one plugin. This is will be more useful on my project due to different reasons.

I figured out that in the plugin event onContentPrepareForm(), we have the opportunity to manipulate the form object.

For instance this code in plugin:

Code: Select all

public function onContentPrepareForm($form, $data) {
        $xml = new SimpleXMLElement('<field
			name="TEST"
			type="radio"
			label="TEST"
			description="TEST"
			class="btn-group btn-group-yesno"
			default="0"
			>
			<option value="1">JYES</option>
			<option value="0">JNO</option>
		</field>');
        $form->setField($xml, null, false, 'editorConfig');
}
will add a radio buttons into tab "Configure Edit Screen".
I try to change fieldset in the method setField() on "images" or "attribs" but it dosent work. Idk why.

voron121
Joomla! Fledgling
Joomla! Fledgling
Posts: 4
Joined: Mon Oct 31, 2022 6:27 pm

Re: How to get article form instance in admin panel?

Post by voron121 » Fri Jun 21, 2024 3:30 pm

The issue is solved. I had redefined methods. Sorry

Advertisement

Post Reply

Return to “Administration Joomla! 3.x”