Costum Field Types

Hello,

how can i create Costum Fields, have you any Documentation?

I will Create a Field for Search in UnsplashAPI and Put the Image ID in a Field.

Have you any tips for me?

Creating a custom field is straightforward, you basically need to inform Cockpit of the field:

create the a tag file, e.g. your-addon/assets/field-yourfieldname.tag

<field-yourfieldname>
  field markup...
  <script>
    js code..., you may invoke addon functions, etc..
  </script>
</field-yourfieldname>

in bootstrap.php:

$app->on('admin.init', function () {
  $this->helper('admin')->addAssets('youraddonname:assets/field-yourfieldname.tag');
});

check in modules/Cockpit/assets/components for the existing core fields

1 Like

you can also just put field-yourfieldname.tag into config/tags folder and it will get aut-loaded (good for quick testing)

3 Likes