承接 shopsys/jsformvalidator-bundle 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

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

shopsys/jsformvalidator-bundle

Composer 安装命令:

composer require shopsys/jsformvalidator-bundle

包简介

Javascript validation for Symfony forms.

README 文档

README

Build and tests Total Downloads

This module enables validation of the Symfony 4 or later forms on the JavaScript side. It converts form type constraints into JavaScript validation rules.

If you have Symfony 4.4 or 5.x - you need to use Version 1.7.x

If you have Symfony 4.* - you need to use Version 1.6.x-dev

If you have Symfony 3.1.* - you need to use Version 1.5.*

If you have Symfony 3.0.* - you need to use Version 1.4.*

If you have Symfony 2.8.* or 2.7.* - you need to use Version 1.3.*

If you have Symfony 2.6.* or less - you need to use Version 1.2.*

1 Installation

1.1 Download FpJsFormValidatorBundle using composer

Run in terminal:

$ composer require "shopsys/jsformvalidator-bundle":"dev-master"

Or if you do not want to unexpected problems better to use exact version.

$ composer require "shopsys/jsformvalidator-bundle":"v1.6.*"

1.2 Enable javascript libraries

There are two ways to initialize javascript's files for this library. You can create a new entry in the webpack or import the main file into your javascript.

1.2.1 Add FpJsFormValidatorBundle to webpack.config.js

Encore
    ...
    .addEntry('app', './assets/js/app.js')
+   .addEntry('FpJsFormElement', './vendor/fp/jsformvalidator-bundle/Fp/JsFormValidatorBundle/Resources/public/js/FpJsFormValidatorWithJqueryInit.js')
    ...
    .configureBabel(null, {
        useBuiltIns: 'usage',
        corejs: 3,
    })
;

And include new entry in your template

+   {{ encore_entry_script_tags('FpJsFormElement') }}
    {{ encore_entry_script_tags('app') }}

1.2.2 Import FpJsFormValidatorBundle in your main javascript

  import $ from 'jquery';
+  import 'path-to-bundles/fpjsformvalidator/js/FpJsFormValidator';
+  import 'path-to-bundles/fpjsformvalidator/js/jquery.fpjsformvalidator';

1.2.3 Use inits in your template

{% block javascripts %}
+   {{ js_validator_config() }}
+   {{ init_js_validation() }}
{% endblock %}

1.4 Add routes

If you use the UniqueEntity constraint, then you have to include the next part to your routing config: app/config/routing.yml

# ...
fp_js_form_validator:
    resource: "@FpJsFormValidatorBundle/Resources/config/routing.xml"
    prefix: /fp_js_form_validator

Make sure that your security settings do not prevent these routes.

2 Usage

After the previous steps the javascript validation will be enabled automatically for all your forms.

  1. Disabling validation
  2. If your forms are placed in sub-requests
  3. If you need to initialize JS validation for your forms separately, or by some event, in this case you need to follow these steps instead of the chapter 1.3

3 Customization

Preface

This bundle finds related DOM elements for each element of a symfony form and attach to it a special object-validator. This object contains list of properties and methods which fully define the validation process for the related form element. And some of those properties and methods can be changed to customize the validation process.

If you render forms with a some level of customization - read this note.

  1. Disable validation for a specified field
  2. Error display
  3. Get validation groups from a closure
  4. Getters validation
  5. The Callback constraint
  6. The Choice constraint. How to get the choices list from a callback
  7. Custom constraints
  8. Custom data transformers
  9. Checking the uniqueness of entities
  10. Form submit by Javasrcipt
  11. onValidate callback
  12. Run validation on custom event
  13. Collections validation

4 Local development

Requirements

  • docker with docker-compose
  • make

Run application

docker-compose up -d --build
make install
# test form will be available at http://127.0.0.1:8080

Run tests

make tests

shopsys/jsformvalidator-bundle 适用场景与选型建议

shopsys/jsformvalidator-bundle 是一款 基于 JavaScript 开发的 Composer 扩展包,目前已累计 148.32k 次下载、GitHub Stars 达 0, 最近一次更新时间为 2022 年 07 月 18 日, 在 PHP 生态内属于活跃度较高的组件。

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

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

围绕 shopsys/jsformvalidator-bundle 我们能提供哪些服务?
定制开发 / 二次开发

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

BUG 修复 & 性能优化

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

项目外包 & 长期维护

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

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

统计信息

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

GitHub 信息

  • Stars: 0
  • Watchers: 0
  • Forks: 54
  • 开发语言: JavaScript

其他信息

  • 授权协议: MIT
  • 更新时间: 2022-07-18