Php Symfony新字段类型

Php Symfony新字段类型,php,forms,symfony,Php,Forms,Symfony,我想在表单中添加自定义字段类型。alias似乎不起作用: bundle_dir/services.yml 我的表单生成器: ... //not working with alias ->add('endedTime', 'extjstime') //this one is working ->add('endedTime', new ExtjsTimeType()) 我的调试: php app/console container:

我想在表单中添加自定义字段类型。alias似乎不起作用:

bundle_dir/services.yml 我的表单生成器:

...
      //not working with alias
      ->add('endedTime', 'extjstime') 
      //this one is working
      ->add('endedTime', new ExtjsTimeType())
我的调试:

 php app/console container:debug code_cats.type.extjstime
[container] Information for service code_cats.type.extjstime
Service Id       code_cats.type.extjstime
Class            CodeCats\PanelBundle\Form\Type\ExtjsTimeType
Tags
    - form.type                      (alias: extjstime)
Scope            container
Public           yes
Synthetic        no
Required File    -
已更新 我的表单生成器是:

namespace CodeCats\PanelBundle\Form\Type;


class ExtjsTimeType extends AbstractType {


    public function getParent()
    {
        return 'text';
    }

    public function getName()
    {
        return 'extjstime';
    }
}
1使用别名

services:
    code_cats.type.extjstime:
        class: CodeCats\PanelBundle\Form\Type\ExtjsTimeType
        tags:
            - {name: form.type, alias: extjstime}
2添加方法getName()


验证ExtjsTimeType::getName()是否返回“extjstime”;如何使用
->add('endedTime',extjstime')
?当我使用extjs时,我有:无法加载类型“extjstime”,可能别名不工作?名称是extjstime,我看到相同的错误无法加载类型“extjstime”,这必须工作。你能清理一下缓存吗
php应用程序/控制台缓存:clear--env=dev
可能它不适用于工厂?在我的控制器中,我创建表单$factory->createNamed(null,new RootType(),$ent);而是$this->createForm(新的RootType(),$ent)
services:
    code_cats.type.extjstime:
        class: CodeCats\PanelBundle\Form\Type\ExtjsTimeType
        tags:
            - {name: form.type, alias: extjstime}
<?php

namespace CodeCats\PanelBundle\Form\Type;

use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolverInterface;

class ExtjsTimeType extends AbstractType
{
    public function buildForm(FormBuilderInterface $builder, array $options)
    {
        // ...
    }

    public function setDefaultOptions(OptionsResolverInterface $resolver)
    {
       // ...
    }

    public function getName()
    {
        return 'extjstime';
    }
}