Get blueprint including global field definitions in a panel field?

In a panel field it’s possible to do this:

$blueprint = $this->page()->blueprint()->yaml();
foreach( $blueprint['fields'] as $key => $item ) {
  print_r($item);
}

The problem is that it does not take into account that there may be global field definitions.

This is kind of the result I’m looking for:

I want it to include the global field definitions as well.

$blueprint = $this->page()->blueprint()->yaml();
foreach( $blueprint['fields'] as $key => $item ) {
  if( ! empty( $item['type'] ) && $item['type'] == 'text' ) {
    echo $item['value'];
  }
}
1 Like

I solved it myself by searching in the core.

This is how it can be done:

$fields = $this->page()->blueprint()->fields($this)->toArray();
  foreach( $fields as $item ) {
    $name = $item['name'];
    $type = $item['type'];

    if( $type == 'textarea') {
      echo $this->page()->$name()->kirbytext();
    }
}
2 Likes