it-blaster/uploadable-bundle

基于 it-blaster/uploadable-behavior 扩展的 Symfony 表单文件类型

v1.1.3 2016-09-27 04:47 UTC

This package is not auto-updated.

Last update: 2024-09-25 15:53:54 UTC


README

Scrutinizer Code Quality Build Status License Total Downloads Latest Unstable Version Latest Stable Version

基于 it-blaster/uploadable-behavior 扩展的 Symfony 表单文件类型。

它提供轻松上传文件、显示文件链接以及在表单中显示复选框控件以便删除它们(仅从数据库中删除)的功能。

安装

将 it-blaster/uploadable-bundle 添加到您的 composer.json 文件中,并运行 composer

...
"require": {
    "it-blaster/uploadable-bundle": "1.0.*"
}
...

在您的 AppKernel.php 中注册此包

...
new Fenrizbes\UploadableBundle\FenrizbesUploadableBundle(),
...

配置 it-blaster/uploadable-behavior

使用方法

现在您可以使用 uploadable 表单类型

...
    ->add('MyFile', 'uploadable')
...

此类型继承了所有 file 类型选项(除 constraints 外)并具有自己的选项

  • removable(布尔值,默认:true)- 显示或隐藏复选框控件以删除
  • remove_label(字符串,默认:'remove')- 复选框控件的标签(如果启用)
  • file_constraints(数组,默认:null)- 对 file 字段的约束

配置

该包只有一个参数 root_path,它确定项目根目录的路径。默认值是 %kernel.root_dir%/../web。您可以在 config.yml 中如下配置它

...
fenrizbes_uploadable:
    root_path: /your/own/path
...

待办事项

  • 删除之前上传的文件