Jump to content

Hook to ProcessPageEdit::buildForm and Repater field


Recommended Posts


I have a hook to ProcessPageEdit::buildForm where I add a custom tab. 

wire()->addHookAfter('ProcessPageEdit::buildForm', function ($event) {
	$page = $event->object->getPage();

	if ($page->template == "news-item" || $page->template == 'organization-news-item') {

		$pageEditTab = $form->find('id=ProcessPageEditContent')->first();
		$form->insertAfter($inputfields, $pageEditTab);

		wire()->addHookAfter('ProcessPageEdit::getTabs', function ($event) {
			$event->return = array_merge(
				array_slice($event->return, 0, 1, true),
				array('change_news_parent' => __('Изменить категорию новости')), // should be identical to the weird name/title above
				array_slice($event->return, 1, null, true)

		$event->return = $form;

I have repeater field in the template for these pages.

The issue is that this hook is also triggered when I add a new item in the repeater field. So the $form becomes the form of repeater page and this part of the code return null


and I get the error about the second argument inside insertAfter method.

I can add if (!$pageEditTab) return;, but it looks unclear for me how I can limit my code only for 'master' page and not items of repeater field.

Thank in advance.

Link to comment
Share on other sites

@Robin S No, there are no problems and actually, I use this code, but I would like to have a more obvious way to detect for which page the hook was triggered.  

$page instanceof RepeaterPage 
$page->template != "repeater_template"


  • Thanks 1
Link to comment
Share on other sites

  • 2 years later...

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

  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Create New...