omouren/document-id-form-bundle
Composer 安装命令:
composer require omouren/document-id-form-bundle
包简介
Provides the "document_id" form type
README 文档
README
Provides the form type "document_id" using Doctrine ODM. Based on the work of Gregwar : FormBundle
Installation
composer require omouren/document-id-form-bundle.
Register the bundle in the application kernel :
<?php // app/AppKernel.php //... public function registerBundles() { $bundles = array( ... new Omouren\DocumentIdFormBundle\OmourenDocumentIdFormBundle(), ... ); ...
Add the following after the twig block to the configuration :
# app/config/config.yml
# Twig Configuration
twig:
...
form_themes:
- 'OmourenDocumentIdFormBundle::document_id_type.html.twig'
Usage
The document_id is a field that contains an document id, this assumes you set up javascripts or any UI logics to fill it programmatically.
The usage look like the document field type one, except that the query returns one unique result. One example :
<?php //... $builder ->add('city', 'document_id', [ 'class' => 'Project\Entity\City', ]) ;
Here ->find($value) will be used.
You can also chose to show the field, by passing the hidden option to false:
<?php //... $builder ->add('city', 'document_id', array( 'class' => 'Project\Entity\City', 'hidden' => false, 'label' => 'Enter the City id' )) ;
Using the property option, you can also use another identifier than the primary key:
<?php //... $builder ->add('recipient', 'document_id', array( 'class' => 'Project\Entity\User', 'hidden' => false, 'property' => 'login', 'label' => 'Recipient login' )) ;
统计信息
- 总下载量: 18
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 3
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: Unknown
- 更新时间: 2016-06-23