定制 konsulting/form 二次开发

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

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

konsulting/form

Composer 安装命令:

composer require konsulting/form

包简介

HTML form builder

README 文档

README

A library to simplify form building in php applications. It uses a template approach, supplied by Plates. It is inspired by the Laravel Collective Form library and a previous generations of form builder developed by Konsulting.

You can use the library in any PHP project, but we have included some helpers for usage within a Laravel Project.

Documentation is still being developed, so please bear with us.

Installation

We recommend using composer to install the library.

composer require konsulting/form-builder

Usage with Laravel

The package will auto-register the Service Provider and Facade in Laravel 5.5+. In earlier versions of Laravel, you will need to manually register them yourself in your config/app.php.

"providers" => [
    ...
    "Konsulting\\FormBuilder\\Laravel\\FormBuilderServiceProvider"
],

"aliases" => [
    ...
    "Form" => "Konsulting\\FormBuilder\\Laravel\\FormBuilderFacade"
]

You will then be able to access the FormBuilder instance though the Facade in your views (or anywhere else you need to).

// For example
Form::text('name', $yourName)->withLabel('Your Name')

Usage outside Laravel

To begin using the form builder, you need to construct it using the Plates Engine (which essentially tells it which templates to use) and a class resolver (which effectively tells the build where to look for each form elements' class).

    use League\Plates\Engine;
    use Konsulting\FormBuilder\FormBuilder;
    use Konsulting\FormBuilder\ClassResolver;

    //...
    
    $builder = new FormBuilder(
        new Engine(__DIR__ . '/../../vendor/konsulting/form-builder/partials/bootstrap3'),
        new ClassResolver('Konsulting\\FormBuilder\\Elements\\')
    );

There is a simple API to build up your form elements. Each element shares a set of common methods, and we have set up the base set of html form elements.

Shared methods

Setting attributes

  • withLabel(label) and withoutLabel
  • withError(message) and withoutError
  • withFeedback(type, message) and withoutFeedback
  • withHelp(message)
  • withAddon(content, position=before|after) - specific addon to the input (e.g. calendar icon to the right of an input box)
  • prepend(content) - place content before the whole html block
  • append(content) - place content after the whole html block
  • withAttributes(['name' => value, ...]) - set a range of attributes, or those without specific setters

Retrieving attributes

  • attributes([array_of_keys_wanted])
  • attributesExcept([array_of_keys_to_exclude])

Form Elements

  • input(type, name, value)
  • checkbox(name, value)
  • radio(name, value)
  • select(name, options, selected)
  • textarea(name, value)
  • date(name, value)
  • time(name, value)
  • datetime(name, value)

Dates and time

Dates and time have an additional method, split(), which is used to generate input boxes that are split into each component of the date/time. There is a DateTimeFormats helper class, which is used to set the formats for user input/display and for persistence.

The helper also contains functions used to help split the date into components or re-combine it based on the settings.

When using the split() method, your dates and times will need to be recombined when validating them, for example.

Contributing

Contributions are welcome and will be fully credited. We will accept contributions by Pull Request.

Please:

  • Use the PSR-2 Coding Standard
  • Add tests, if you’re not sure how, please ask.
  • Document changes in behaviour, including readme.md.

Testing

We use PHPUnit for this package.

Run tests using PHPUnit: vendor/bin/phpunit

konsulting/form 适用场景与选型建议

konsulting/form 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 385 次下载、GitHub Stars 达 0, 最近一次更新时间为 2018 年 06 月 11 日, 在 PHP 生态内属于活跃度较高的组件。

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

围绕 konsulting/form 我们能提供哪些服务?
定制开发 / 二次开发

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

BUG 修复 & 性能优化

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

项目外包 & 长期维护

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

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

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2018-06-11