Skip to content

Instantly share code, notes, and snippets.

@arfaram
Last active August 6, 2018 11:27
Show Gist options
  • Save arfaram/c7242f4e1d1252bbcfe2deb5ab89810d to your computer and use it in GitHub Desktop.
Save arfaram/c7242f4e1d1252bbcfe2deb5ab89810d to your computer and use it in GitHub Desktop.
FieldType custom edit template in eZ Platform

Solution 1:

Add in config.yml as global

twig:
    #...
    form_themes:
        - 'AcmeTestBundle:adminui/field:my_field_template.html.twig'

Solution2:

Add it in your custom bundle:

namespace AcmeTestBundle\DependencyInjection;

//...

class AcmeTestBundleExtension extends Extension implements PrependExtensionInterface
{
    public function prepend(ContainerBuilder $container)
    {
        //...
        $container->prependExtensionConfig( 'twig', array( 'form_themes' => array( '@AcmeTest/adminui/field/my_field_template.html.twig' ) ) );
    }

Template example:

my_field_template.html.twig

{%- block ezplatform_fieldtype_YOUR-FIELDTYPE-IDENTIFIER_row -%}

    {% set wrapper_attr = wrapper_attr|default({})|merge({'class': 'my-css-class'}) %}

    {{ block('form_widget') }}
    {#{  block('form_row_fieldtype') }#}

{%- endblock -%}

Change : YOUR-FIELDTYPE-IDENTIFIER with your FieldType identifier.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment