Jump to content

How to add a button after determined field on a page edit form?


Jacek
 Share

Recommended Posts

I'm coding my first module now. I've just managed to add a button to the page edit form but am not content with its placing. Is there any way to place it just next to the input field? I've marked the desired place with the arrow on the attached screenshot.

My current code:

$this->addHookAfter('ProcessPageEdit::buildFormContent' , $this, 'addButton');

public function addButton($event){

$form = $event->return;

$f =$this->modules->InputfieldSubmit;

...

$form->insertAfter($f, $form->get("bgg_id"));

}

"bgg_id" is the name of the targeted field.

 

Screenshot_2018-07-31-01-18-44.jpg

Link to comment
Share on other sites

Hook it in your in the inputfield's render's method:

 $this->addHookAfter('InputfieldText::render', $this, 'addButton');

In the addButton method, check for the field's name, so it doesn't render everywhere.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...