Jump to content

page reference, "new pages created from field", but filled out with more than just title?


chcs
 Share

Recommended Posts

In the page reference field, one can create new pages if they enable that option. However, the "new" page only gets the title field filled out.

Q: Is there a way to expand on this so a user can fill in more fields from the new page? Either in-line or via modal?

 

Link to comment
Share on other sites

If inside page field setup is checked "Allow new pages to be created from field", there is option to create new page in modal window using hook method inside "site/ready.php".
Please note to write page field name inside if statement.

// ready.php

$this->addHookAfter('InputfieldPage::renderAddable', function ($event){

	$inputfield = $event->object;

	// please note: inside if statement need to write page field name!
	if ($inputfield->name == 'your_page_field_name') //<= here
		{
		$link = $this->wire('config')->urls->admin . 'page/add/?parent_id=' . $inputfield->parent_id . '&modal=1';
		$out = '<p><a href="' . $link . '" target="_blank" class="pw-modal pw-modal-large">
				   <i class="fa fa-plus-circle"></i> Create New</a></p>';
		$event->return = $out;
		return $event->return;
		}
	});

Regards.

  • Like 3
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...