定制 becklyn/ordered-form-bundle 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

becklyn/ordered-form-bundle

最新稳定版本:1.4.0

Composer 安装命令:

composer require becklyn/ordered-form-bundle

包简介

This bundle adds functionality for ordering form elements

README 文档

README

A bundle that makes form fields sortable.

Installation

composer require becklyn/ordered-form-bundle

Usage

This bundle adds a new form option called position:

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

class SomeForm extends AbstractType
{
    /**
     * @inheritDoc
     */
    public function buildForm (FormBuilderInterface $builder, array $options) : void
    {
        $builder
            ->add("field", null, [
                "position" => /* some value */
            ]);
    }
}

The supported values are:

Value Description
"position" => "first" Places the element as the first element in the form.
"position" => "last" Places the element as the last element in the form.
"position" => 42 A simple sort order (the lower the number, the more at the top it is). Works with any integer.
"position" => ["before" => "otherfield"] Places the field before another one.
"position" => ["after" => "otherfield"] Places the field after another one.

Caveats

This bundle focuses on speed, so the sorting is not perfect. As it is pretty easy to create a conflicting, this bundle tries a best-effort sorting, but this implies:

  • A first field isn't guaranteed to be the first one (eg. if there are multiple first).
  • before and after only guarantee the relative order, not how big the distance is between these fields (it tries to place them immediately next to each other).

If the configuration of the form is sensible and conflict-free, then the order will work as expected.

统计信息

  • 总下载量: 56.61k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 5
  • 点击次数: 1
  • 依赖项目数: 2
  • 推荐数: 1

GitHub 信息

  • Stars: 5
  • Watchers: 0
  • Forks: 1
  • 开发语言: PHP

其他信息

  • 授权协议: BSD-3-Clause
  • 更新时间: 2018-02-15