Create your own Field Types for Block Designer

Creating Field Types for Block Designer is rather simple. Make for example a "BlockDesigner" directory in your package. We assume you have a "awesome_package" package. Your package folder is here:

/packages/awesome_package/handle

Your Block Designer directory is here:

/packages/awesome_package/handle/BlockDesigner

Create a "FieldType" directory, within that, to drop in all your field types for Block Designer.

/packages/awesome_package/handle/BlockDesigner/FieldType

So for each field type you make, you make a new folder within the directory above. Let's make a "Test" field type and let's create the PHP file as well:

/packages/awesome_package/handle/BlockDesigner/FieldType/TestFieldType/TestFieldType.php

OK, cool. Doing good so far. Let's have some content in it:

<?php namespace Concrete\Package\AwesomePackage\BlockDesigner\FieldType\TestFieldType;

defined('C5_EXECUTE') or die("Access Denied.");

class TestFieldType extends \RamonLeenders\BlockDesigner\FieldType\FieldType

{

protected $ftHandle = 'test';
protected $canRepeat = false;

public function getFieldName()

{
     return t("Test Field Type");

public function getFieldDescription()

{
     return t("Some description here");
}

public function getViewContents()
{
     return '<?php echo "We want to test a Field Type"; ?>';
}
// Your other needed functions, see Block Designer/Block Designer Pro field types for examples
}

Now in your Package's controller.php file, you'd need to tell Block Designer which directory is your Block Designer directory. That could be in the /src directory or somewhere else. For this example, we did this in /awesome_package/BlockDesigner directory. Just to show you can place it anywhere and autoload it yourself. So use the "" function to tell Block Designer that, like this:

public function getBlockDesignerDirectory(){
     return 'BlockDesigner';
}

Since we didn't load the files in yet, you can make place the autoload code in the "on_start" function for example or anywhere you'd like to do so (just make sure it's loaded, otherwise your Field Types won't show up):

$strictLoader = new \Symfony\Component\ClassLoader\Psr4ClassLoader();
$strictLoader->addPrefix('Concrete\\Package\\AwesomePackage\\BlockDesigner', DIR_PACKAGES . '/awesome_package/BlockDesigner');
$strictLoader->register();

It's also possible to use the default $pkgAutoloaderRegistries array like this:

protected $pkgAutoloaderRegistries = [
     'BlockDesigner' => 'Concrete\\Package\\AwesomePackage\\BlockDesigner',
];

That's it. You're all set. You can make more Field Types now. Have fun!