我的应用程序正在运行,但是当我使用自定义表单字段类型(shtumi_daterange)时,例如:
public function buildForm(\Symfony\Component\Form\FormBuilderInterface $builder, array $options)
{
$dateRange4 = new DateRange('m/d/Y');
$dateRange4->parseData('03/27/2012 - 04/05/2012');
$builder->add('builddate', "shtumi_daterange", array('required'=>false, 'default'=>$dateRange4));
}
发生此错误:
Uncaught exception 'Symfony\Component\Form\Exception\FormException' with
message 'Could not load type "shtumi_daterange"' in
../vendor/symfony/form/Symfony/Component/Form/FormRegistry.php:95
我想,我需要类似的东西:
<?php
$app->register(new Silex\Provider\TwigServiceProvider(), array(
'twig.path' => $path_ext_dir_abs . '/views',
'twig.form.templates' => array('form_div_layout_custom.html.twig'),
'form.type.shtumi_daterange' => 'Shtumi\UsefulBundle\Form\Type\DateRangeType',
));
但我只是不知道/找到正确的符号!
从symfony 文档中,我找到了如何注册自定义表单字段类型的示例,但我无法对其进行转换以使其与 silex 一起运行:
services:
form.type.gender:
class: Acme\DemoBundle\Form\Type\GenderType
arguments:
- "%genders%"
tags:
- { name: form.type, alias: gender }