eZ Platform Discussions

FieldType trouble


#1

Hi all!

I’m trying to develop a fieldtype, and I have followed the tutorial and the updated info for v2 in the cookbook. I also checked out Netgens EnhancedSelection.

I’ve run into all sorts of problems, but currently I’m stuck with this error from Felix\PolygonFieldTypeBundle\Form\Type\FieldType\PolygonFieldType:

Type error: Too few arguments to function Felix\PolygonFieldTypeBundle\Form\Type\FieldType\PolygonFieldType::__construct(), 0 passed in /home/felix/ezplatform/vendor/symfony/symfony/src/Symfony/Component/Form/FormRegistry.php on line 86 and exactly 1 expected

In PolygonFieldType.php I have:

private $fieldTypeService;

public function __construct( FieldTypeService $fieldTypeService )
{
    $this->fieldTypeService = $fieldTypeService;
}

As far as I can see, I am providing an argument.

What could be reason for this?


#2

Hi @felix,

My guess is that it’s Symfony’s autowire feature acting up. It cannot detect the argument of your field type service. You can probably solve it by creating manually a dedicated service definition for your field type and specify its arguments there.


#3

Thanks Edi.

Turned out I had a type in my fieldtypes.yml.

Now on to the next issue. How do I set up templates? I tried to follow the tutorial etc, but it obviously doesn’t work as I get this error:

An exception has been thrown during the rendering of a template ("Cannot find 'ezpolygon_field' template block.").

#4

You can register field view and field definition edit/view templates like this: https://github.com/netgen/NetgenEnhancedSelectionBundle/blob/master/bundle/Resources/config/ezplatform.yml

You need to activate that YML file in your DI extension class: https://github.com/netgen/NetgenEnhancedSelectionBundle/blob/master/bundle/DependencyInjection/NetgenEnhancedSelectionExtension.php#L43-L54