承接 webfox/laravel-forms 相关项目开发

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

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

webfox/laravel-forms

Composer 安装命令:

composer require webfox/laravel-forms

包简介

A Laravel form package

README 文档

README

By default the views are setup for beagle Javascript not included

Directives

Form Open

@form(['update' => route('some-model.store', [$model]), 'model' => $model, 'files' => true, 'extra' => [...]])
@form(['store' => route('some-model.store'), 'files' => true, 'extra' => [...]])
@form(['delete' => route('some-model.delete'), 'files' => true, 'extra' => [...]])
@form(['get' => route('search.route'), 'extra' => [...]])

Notes

  • Using any of these methods will automatically append the csrf _token and correct route type _method fields.
  • If a model is passed via the 'model' key, We will use it's data to populate the form fields value.
  • Anything passed via the 'extra' array will be appended as attributes to the form.

Form Close

@endform

Notes

  • The form is actually a component, which means you need to close it after you're done.
  • This will also unbind the 'model' so future forms on the same page are not affected.

Form Field

Now we get into the fun stuff. The minimum required for a form field is a name

@formField(['name' => 'first_name'])

This will render a type="text" form field wrapped in a form group with the label of First Name and an appropriate value, Additionally this will handle displaying server validation errors.

@formField(['name' => 'name', 'label' => 'Your Name'])

This will render as above, however the label will be Your Name

@formField(['name' => 'name', 'label' => false])

This will render as above, however there will be no label

@formField(['name' => 'work_email', 'type' => 'email' ])

This will render a type="email" form field following the previous rules

@formField(['name' => 'role', 'options' => ['k' => 'v', 'k2' => 'v2']])

This will render a select with the given options. If no value is found for this field we will also prepend an empty <option> tag

@formField(['name' => 'roles', 'options' => ['k' => 'v', 'k2' => 'v2'], 'extra' => ['multiple']])

This will render a select with the given options, additionally the name on the select will be roles[]

@formField(['name' => 'first_name', 'extra' => ['required', 'data-boolean', 'data-something' => 'value']])

This will render a field with the following additional attributes required data-boolean data-something="value"

Calculating Values

The following order of precedence is used for calculating values for a form 0. Input matching the name via Laravels old($fieldName) helper. 0. Attributes from the model provided to @form 0. Values passed in directly e.g. @formField(['name' => 'name', 'value' => 'John']).

Additionally if the final calculated value is an object and has a getValue method, this will be called.

Note on old input and multiple forms...

Unfortunately, there's no way to scope Laravels old($fieldName) helper, meaning that if one form on a page has old input, all fields on the page with the same name will be populated with the old input. This is not a limitation of this package, rather it is a limitation of Laravel's old input handling.

A note about templates, backward compatibility and support

We've open sourced this package so you can use it too, however it is primarily designed for our inhouse usage, meaning some of the templates have specific rules that require javascript from our templates to run, additionally we'll be releasing often to add new features and fixes we need, but it may break your work.

Rather than using this package directly, we suggest you fork it and maintain a copy for your organisation.

IDE Helper

If you don't have them already, add the following to your projects .idea/blade.xml file so PHPstorm knows about the directives

<data directive="@endform" />
<data directive="@form" injection="true" prefix="&lt;?php function x(array $options) {}; x(" suffix="); ?&gt;" />
<data directive="@formField" injection="true" prefix="&lt;?php function x(array $options) {}; x(" suffix="); ?&gt;" />

webfox/laravel-forms 适用场景与选型建议

webfox/laravel-forms 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 715 次下载、GitHub Stars 达 1, 最近一次更新时间为 2019 年 04 月 05 日, 在 PHP 生态内属于活跃度较高的组件。

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

围绕 webfox/laravel-forms 我们能提供哪些服务?
定制开发 / 二次开发

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

BUG 修复 & 性能优化

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

项目外包 & 长期维护

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

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

统计信息

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

GitHub 信息

  • Stars: 1
  • Watchers: 3
  • Forks: 3
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2019-04-05