Jump to content

Custom Field in Page SettingsTab


blackeye1987
 Share

Recommended Posts

Hi Everyone,

i couldn't find a way to put a custom field into the settings tab

i'd need that field only as a superuser, to hide pages from my own search engine.
best would be a custom status, but a checkbox in the settingstab would be the smoothest solution

i wasn't able to find anything like that in the forum so far.


feel free to move the thread, if i am in the wrong subforum
 

Link to comment
Share on other sites

Here's a short snippet for site/ready.php that hooks after ProcessPageEdit::buildForm and moves a regular field (named "testfield here") from the Content tab to Settings. The methods used are from the InputfieldWrapper class.

<?php

wire()->addHookAfter("ProcessPageEdit::buildForm", null, "moveFieldToSettings");

function moveFieldToSettings(HookEvent $event) {
	$form = $event->return;
	
	$field = $form->find("name=testfield")->first();
	
	if($field) {
		$settings = $form->find("id=ProcessPageEditSettings")->first();
		// Alternatively, find a specific field to insert before/after:
		// $settings = $form->find("name=template")->first();
		
		if($settings) {
			$form->remove($field);
			$settings->append($field);
			// In the alternative, insert before or after the found field:
			// $form->insertBefore($field, $settings);
		}
	}	
}

 

  • Like 12
Link to comment
Share on other sites

@LostKobrakai - this would miss the feel of having it in the settings tab, besides yes i could make a custom settingsTab, but this would also miss my approach.

i am not looking for a quick solution more for a clean or even expandable solution.

using @BitPoet's approach , i am more flexible and able to communicate with my team and the customer.

having hidden fields through content tabs might give an irritational feel when working with customers

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...