palmtree/form
Composer 安装命令:
composer require palmtree/form
包简介
Form builder with Bootstrap v5/v4 classes, validation, Recaptcha support, AJAX submissions and more
README 文档
README
PHP form builder with Bootstrap classes, validation, CSRF protection, data binding, Google Recaptcha and hCaptcha support, plus other goodies.
Requirements
- PHP >= 8.3
Installation
Use composer to add the package to your dependencies:
composer require palmtree/form
Optional: Install the NPM package for AJAX form submission, CAPTCHA support and form collections:
npm install @palmtree/form
Usage Example
Build
use Palmtree\Form\FormBuilder; use Palmtree\Form\Captcha\GoogleRecaptcha; use Palmtree\Form\Captcha\HCaptcha; $builder = (new FormBuilder('my_form')) ->add('name', 'text', ['error_message' => 'Please enter your name']) ->add('email_address', 'email', [ 'help' => 'We will never share your email with anyone', ]) ->add('message', 'textarea', [ 'required' => false, 'label' => 'Enter your message', ]) ->add('recaptcha', 'captcha', [ 'captcha' => new GoogleRecaptcha('<site_key>', '<secret>'), //'captcha' => new HCaptcha('<site_key>', '<secret>'), ]); $builder->add('send_message', 'submit'); $form = $builder->getForm(); // Set $form to some variable accessible in a view
Render
<div class="container"> <?= $form->render(); ?> </div> <!-- Optional JS for AJAX submissions, CAPTCHA support and form collections --> <script src="https://unpkg.com/@palmtree/form@latest/dist/palmtree-form.pkgd.min.js"></script>
Process
$form->handleRequest(); if ($form->isSubmitted() && $form->isValid()) { // Send an email/save to database etc $name = $form->get('name')->getData(); }
See the examples directory for examples using AJAX, file uploads, collections and more.
Documentation
View the documentation for more advanced usage.
Examples
The simplest way to run the examples is run the serve.sh script. This script starts a small PHP Docker container and serves the examples using PHP's built-in web server.
./examples/serve.sh
License
Released under the MIT license
palmtree/form 适用场景与选型建议
palmtree/form 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 5.27k 次下载、GitHub Stars 达 38, 最近一次更新时间为 2016 年 10 月 25 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「form」 「bootstrap」 「recaptcha」 「ajax」 「captcha」 「form-builder」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 palmtree/form 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 palmtree/form 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 palmtree/form 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Client library for reCAPTCHA with proxy support, a free service that protects websites from spam and abuse.
Diese Contao 4 Erweiterung stellt Google reCAPTCHA V2 in Form eines neuen Formularfeldes im Formulargenerator bereit. This extension provides Google reCAPTCHA V2 in the form of a new form field in the form generator of Contao Open Source CMS.
A simple and easy to use Google ReCaptcha v3 package for Laravel
Views for the package MedicOneSystems Livewire Datatables with Bootstrap 4
A Laravel Filament Forms slug field.
A jQuery augmented PHP library for creating and validating HTML forms
统计信息
- 总下载量: 5.27k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 38
- 点击次数: 12
- 依赖项目数: 1
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2016-10-25