lrotherfield / form
为Symfony2表单组件提供的附加组件
2.0.0
2016-03-31 19:42 UTC
Requires
- php: >=5.3.2
- doctrine/common: >=2.2
- symfony/form: >=2.2
This package is not auto-updated.
Last update: 2024-09-14 14:04:07 UTC
README
##附加表单组件
这一系列类为Symfony2表单组件添加功能。
###安装
要安装表单组件,只需将其添加到您的composer.json需求中
"require": {
"lrotherfield/form": "2.0.x-dev",
}
然后运行 composer.phar update
###隐藏实体类型
要使用隐藏实体类型,您需要在config.yml或services.yml文件中将它注册为一个服务
services:
lrotherfield.form.type.hidden_entity:
class: Lrotherfield\Component\Form\Type\HiddenEntityType
arguments:
- @doctrine.orm.entity_manager
tags:
- { name: form.type, alias: hidden_entity }
然后您可以使用表单构建器来使用这个类型
public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder
//...
->add('example', 'hidden_entity', array(
"class" => "Lrotherfield\\Bundle\\ExampleBundle\\Entity\\ExampleEntity"
));
;
}
唯一的额外要求是 "class" 选项,它必须是实体对象的完全限定命名空间,您希望在该转换中使用该实体