2.4.1. | Global Field Definitions don't work

Hi there,

I’m trying to set up global field definitions.

  1. I’ve got a fresh 2.4.1.-starterkit.
  2. I followed exactly these steps: https://getkirby.com/docs/panel/blueprints/global-field-definitions and created the example imageselect - definition in blueprints/fields/imageselect.yml
  3. If I use it noe in my blueprints, I get the following error: The imageselect field is missing. Please add it to your installed fields or remove it from your blueprint

Is this a bug?

Also most other plugins (footenotes, …) , and fields (multiselect,…) seem to working not with 2.4.1…
Whre is my mistake?
Where I can get a stable release, which is able to use all the great extensions?

Thank You! André

In order to help you, please share the code you have of the global field and of the blueprint you’re trying to use it.

2.4.1 is the latest stable version and global field definitions and all up-to-date plugins should work correctly.

So I guess there is some mistake somewhere. But as @pedroborges already mentioned, without any code, we can’t really help you… :pensive:

Thank you for your answers! As I wrote, I followed these instructions. So I made a folder fields in blueprints.
In this folder I wrote the file imageselect.yml with following content:

# /site/blueprints/fields/imageselect.yml

label: Select an image
type: select
options: images 

In the blueprints/home.yml I wrote this:

# /site/blueprints/home.yml 

title: Home

pages: false

fields:
  title:
    label: Title
    type: text

  intro:
    label: Intro
    type: textarea

  text:
     type: textarea

  pic:
      type: imageselect

If I go to the panel on home I get this Error:

The imageselect field is missing. Please add it to your installed fields or remove it from your blueprint

I did not change anything on the starterkit, except the Rewritebase in .htaccess

So the select.php is the original file from starterkit:

# /panel/app/fields/select
<?php

class SelectField extends BaseField {

  public function __construct() {

      $this->type    = 'select';
      $this->options = array();
      $this->icon    = 'chevron-down';

  }

  public function options() {
      return FieldOptions::build($this);
  }

  public function option($value, $text, $selected = false) {
    return new Brick('option', $this->i18n($text), array(
      'value'    => $value,
      'selected' => $selected
    ));
   }

  public function input() {

    $select = new Brick('select');
    $select->addClass('selectbox');
    $select->attr(array(
       'name'         => $this->name(),
       'id'           => $this->id(),
       'required'     => $this->required(),
       'autocomplete' => $this->autocomplete(),
       'autofocus'    => $this->autofocus(),
       'readonly'     => $this->readonly(),
       'disabled'     => $this->disabled(),
    ));

    $default = $this->default();

    if(!$this->required()) {
        $select->append($this->option('', '', $this->value() == ''));
    }

    if($this->readonly()) {
       $select->attr('tabindex', '-1');
    }

    foreach($this->options() as $value => $text) {
       $select->append($this->option($value, $text, $this->value() == $value));
    }

    $inner = new Brick('div');
    $inner->addClass('selectbox-wrapper');
    $inner->append($select);

    $wrapper = new Brick('div');
    $wrapper->addClass('input input-with-selectbox');
    $wrapper->append($inner);

    if($this->readonly()) {
       $wrapper->addClass('input-is-readonly');
    } else {
       $wrapper->attr('data-focus', 'true');
    }

    return $wrapper;

    }

    public function validate() {
      return array_key_exists($this->value(), $this->options());
    }

}

Hope, these Informations are a good startpoint.

Thank You!

Instead of:

pic:
  type: imageselect

Use:

pic: imageselect

That’s how Kirby knows if it should look for a field or global field definition.

F**K. Thank You!!! I’m not so familiar with Kirby 2 since I used Kirby 1 so long… ;-):thumbsup:

About the problems with some plugins I’ll make a new topic. Hoping, there is a simular light-weight-problem.

BW André

As regards the plugins, please tell us where you installed them. The best way would be to post your file structure, often, it is a naming problem. The folder name in /site/plugins/ must match the name of the main plugin file. If you download a plugin from GitHub, for example, you often end up with a folder called “pluginname-master”. In such a case, you have to rename the folder.