Costum Field Types


#1

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?


#2

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


#3

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