定制 nowo-tech/form-kit-bundle 二次开发

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

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

nowo-tech/form-kit-bundle

Composer 安装命令:

composer require nowo-tech/form-kit-bundle

包简介

Symfony bundle to reduce repetitive form field options: convention-based labels/placeholder/help (form_snake.field_snake.*), configurable attr/row_attr/translation_domain, and cascading option merge (global → field type → form → field). Symfony 7.4|8.

README 文档

README

CI Packagist Version Packagist Downloads License PHP Symfony GitHub stars Coverage

Found this useful? Install from Packagist and give the repo a star on GitHub.

Symfony bundle to reduce repetitive form field options: convention-based translation keys (form_snake.field_snake.label, .placeholder, .help), configurable defaults and multiple configs via YAML, and cascading option merge (global → field type → form → field).

Minimum requirements: PHP 8.2 and Symfony 7.4. Also compatible with Symfony 8.0 and 8.1 (require PHP 8.4+).

Features

  • Convention-based labels, placeholder and help: Default translation keys are {form_snake}.{field_snake}.label, .placeholder, .help. Set any to false in field options to disable.
  • Multiple configs: Define named configs (e.g. default, bootstrap) with translation_domain, defaults.attr, defaults.row_attr, and per-field-type options. Choose the active config per form via setFormKitConfigName().
  • Cascading merge: Options are merged in order: config defaults → field type → field options. Explicit field options override.
  • Trait or base class: Use FormOptionsTrait with FormOptionsMerger (inject via service), or extend FormKitAbstractType for snake_case type names with FormTypeMap (same option-merging model via FormOptionsMerger).
  • Phase 2 helpers: addText(), addEmail(), addTextarea(), addPassword(), addUrl(), addInteger(), addNumber(), addCheckbox(), addChoice() — pass only field name and options.
  • Choice presets: addSelect(), addMultiSelect(), addChoiceRadios(), addChoiceCheckboxes(), plus addMultiSelectSelectAll() when nowo-tech/select-all-choice-bundle is installed (optional Composer suggest).
  • FQCN helpers: addAutocompleteField() for Symfony UX Autocomplete types, addCKEditorField() when friendsofsymfony/ckeditor-bundle is installed (CKEditor 4).
  • Model transformers: addSwitchType(), addJsonType(), addBoolType(), addMoneyType(), addCsvType() (same helpers on FormKitControllerTrait with *Type suffix).
  • Build from array: buildFormFromArray($builder, $fields) — define all fields in one array (type as FQCN with FormOptionsTrait, or snake_case with FormKitTrait).
  • Optional types: Built-in type map includes optional Symfony UX types (e.g. Dropzone, Cropper) and A2lix Translations when the corresponding package is installed. Extend via type_map in config.
  • Form type extensions: InputGroupExtension (input_group_prefix / input_group_suffix), RequiredLabelSuffixExtension (suffix for required labels from config), HelpModalExtension (optional help_modal on fields + bundled help-modal.js, Bootstrap 4/5, Tailwind, Foundation; optional Twig shell templates). See Configuration and Usage.

Installation

composer require nowo-tech/form-kit-bundle

With Flex, the recipe creates config/packages/nowo_form_kit.yaml. Otherwise register the bundle in config/bundles.php and add the config file manually. See docs/INSTALLATION.md.

Quick usage

  1. Configure (optional) — edit config/packages/nowo_form_kit.yaml: set default_config, configs (each with alias, translation_domain, defaults, field_types), and optionally type_map for custom or UX types.

  2. Register your form as a service and inject FormOptionsMerger:

# config/services.yaml
App\Form\UserProfileType:
  tags: ['form.type']
  calls:
    - setFormOptionsMerger: ['@Nowo\FormKitBundle\Form\FormOptionsMerger']
  1. Use the trait in your form type (Phase 2 or array):
use Nowo\FormKitBundle\Form\FormOptionsTrait;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\FormBuilderInterface;

class UserProfileType extends AbstractType
{
  use FormOptionsTrait;

  public function buildForm(FormBuilderInterface $builder, array $options): void
  {
    $this->addText($builder, 'full_name', []);
    $this->addEmail($builder, 'email_address', []);
    // Or: $this->buildFormFromArray($builder, ['full_name' => TextType::class, 'email_address' => EmailType::class]);
  }
}
  1. Add translations for keys like user_profile.full_name.label, user_profile.full_name.placeholder, user_profile.full_name.help in your translation domain.

Demos

The bundle includes demos (Symfony 7 and 8) that run with FrankenPHP (Caddy + PHP in Docker). docker-compose defaults to APP_ENV=dev, so the entrypoint uses Caddyfile.dev (no PHP worker), and Twig/PHP changes are visible on refresh. Worker mode applies to a production-style setup — see docs/DEMO-FRANKENPHP.md. Each demo has:

  • Locale in the URL — routes are under /{locale}/… (en, es, fr, de); / redirects to the default locale.
  • FormType example (contact, buildFormFromArray), help modal sample (help-modal.js + assets:install; include @NowoFormKit/help_modal/shells.html.twig for overridable modal shells).
  • Form built in the controller (FormKitControllerTrait / FormOptionsMerger::resolve()).
  • Search, example, Dropzone, Cropper, translations (A2lix), nested, data transformers, choice fields (select / multiselect / radios / checkboxes; optional Select All Choice on Symfony 7/8 demos), Nowo special fields (OTP, phone, password, icon selector, Tiptap, CKEditor 5 — see demo/README.md), CKEditor (FOSCKEditorBundle), UX Autocomplete, multi-step wizard.

Run a demo via Docker/Make from the bundle root; see demo/README.md and docs/CONTRIBUTING.md.

For CSS frameworks, see docs/USAGE.md for ready-to-use configuration examples for Bootstrap 5 and Tailwind CSS.

Documentation

Developer-facing docs and comments (Markdown, PHPDoc, JSDoc) are English only; see Contributing — Language policy.

Additional documentation

Tests and coverage

  • Tests: PHPUnit (PHP), Vitest (TypeScript)
  • PHP: 99.59%
  • TS/JS: 100%
  • Python: N/A

License

MIT. See LICENSE.

nowo-tech/form-kit-bundle 适用场景与选型建议

nowo-tech/form-kit-bundle 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 8 次下载、GitHub Stars 达 0, 最近一次更新时间为 2026 年 03 月 02 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「symfony」 「translation」 「form」 「bundle」 「options」 「help」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

我们在过去多个企业项目中使用过 nowo-tech/form-kit-bundle 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 nowo-tech/form-kit-bundle 我们能提供哪些服务?
定制开发 / 二次开发

基于 nowo-tech/form-kit-bundle 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 8
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 34
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2026-03-02