Jump to content

Create new page - Parent page selection - Change/modify select field for parent page selection?


grimezy
 Share

Recommended Posts

Hey everyone,

Wasn't sure if this is possible but am wondering if anyone had a solution to this.  Perhaps with a hook or something?

A client has many parent pages to select from when creating a new page and they are then asked which parent page should this new page be created.  A select field is then used to populate the list but this is a very big list.  500+ and growing which isn't that bad, but their employees are using iPads and I don't think the on-screen keyboard opens when targeting a select field and I don't think there is a way to force open the on-screen keyboard to search easier on the list... they have to scroll continuously and this is becoming an issue.  It would be a lot more efficient for them to search for the parent page using a auto-complete/search select field if there are many items to list.  Is there any way this can be achieved? 

Thanks!

Link to comment
Share on other sites

Sure. Here's a mini-Tutorial how you can find what you need yourself:

Whenever you add a page you view the page /processwire/page/add. That's the page with ID #6 and it lives in your page tree in Admin > Pages > Add Page. If you edit this page you see that this page uses the process "ProcessPageAdd".

So you can inspect that file in your IDE by opening wire/modules/Process/ProcessPageAdd/ProcessPageAdd.module

There you see the ___execute() method which is the method that renders your page. There you see that at the very end it renders the form and that form is built some lines above by calling buildForm(). If you have a look at that method you see that it is hookable, so you can modify that form by hooking into "ProcessPageAdd::buildForm"

<?php
// in site/ready.php
$wire->addHookAfter("ProcessPageAdd::buildForm", function($event) {
  $form = $event->return;
  $form->add([
    'type' => 'markup',
    'label' => 'foo',
    'value' => 'bar',
  ]);
});

Hope that helps.

  • Like 1
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

  • Recently Browsing   0 members

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