Custom Form Field current page title?

How can I get the current page title, into my custom form field? I can see the slug in my URL but there might be a better way than trying to extract it?

<?php
class TransparentField extends BaseField{
	public function __construct() {
		$this->type = 'transparent';
	}

	public function content() {
		// echo $page->title();
		return 'something';
	}
	
}

This should work:

$this->page()->title();
2 Likes

That worked! Thanks so much for all help so far. You also seems like some kind of a Wonder Woman in the world of Kirby.

Suggestion

It does not follow the same pattern as in the template. If it would I did not have to ask this question.

$this->page()->title();
$page()->title();

Is this documented somewhere? If not, it definitely should be.

Thanks for the feedback. I’ve just added documentation about this.