Register plugin with set?

This is a gist about register plugin stuff with set. I don’t understand how to use it.

Let’s say I have this in my plugin:


The first two rows are two fields that needs to be registered and the last is the plugin init file where I want to register the fields. How is that done in this case?

Can I do this and it simply “fake” that the fields are in these places, but they are still inside the plugin folder?

$kirby->set('field', 'myfield', 'fields/myfield');
$kirby->set('field', 'myfield2', 'fields/myfield2');

echo 'Hello from myplugin.php';

I haven’t used the new syntax yet, but I’d guess that the last parameter describes the folder where the field really is inside, starting from the plugin’s main file (or where ever you register the field). So in your case just myfield. The second parameter describes the field name you’d use with type: myfield in your blueprints. At least this is how I understood the syntax :wink:

The paths need to be absolute:

$kirby->set('field', 'myfield',  __DIR__ . DS . 'fields' . DS . 'myfield');
$kirby->set('field', 'myfield2', __DIR__ . DS . 'fields' . DS . 'myfield2');

echo 'Hello from myplugin.php';
1 Like

The field work. The assets, like css does not.

Are you registering the assets in the field? If so, could you please post a reduced example of the code that doesn’t work so that I can reproduce this?

In my plugin I just have this:

$kirby->set('field', 'meta',  __DIR__ . DS . 'field');

My plugin starts like this:

class MetaField extends BaseField {
	static public $fieldname = 'meta';
	static public $assets = array(
		'js' => array(
		'css' => array(

	public function input() {
// ... More code...

Do I need to set the assets as well? Or do I need to change them somehow? The assets now are inside /site/plugins/meta/field/assets/.

That looks good. I believe this is a bug in the Panel. It seems like it doesn’t register the assets for fields outside of the main fields directory. Could you please open an issue in the Panel repo?

It’s done! Thank you!