mzur/kirby-form
Composer 安装命令:
composer require mzur/kirby-form
包简介
A form helper for Kirby-based websites, using the Post/Redirect/Get pattern.
README 文档
README
This is a fork of jevets\kirby-form.
A helper library for working with Kirby forms, using the Post/Redirect/Get design pattern.
Quick Example
$form = new Form([ 'name' => [ 'rules' => ['required'], 'message' => ['Name is required'] ], 'phone' => [], ]); if ($form->validates()) { // Validation passed // Do something with the data }
Installation
Install with composer:
# Kirby 2 composer require mzur/kirby-form:^1.0 # Kirby 3 composer require mzur/kirby-form:^2.0
Basic Example
This example assumes you're using page controllers in Kirby and that your page's URI is /my-page.
// site/templates/my-page.php <?php snippet('header') ?> <?php snippet('form-errors', ['form' => $form]) ?> <form method="POST"> <input name="name" value="<?= $form->old('name') ?>"> <input name="phone" value="<?= $form->old('phone') ?>"> <?= csrf_field() ?> <input type="submit" value="Submit"> </form> <?php snippet('footer') ?>
// site/snippets/form-errors.php <?php if (count($form->errors()) > 0): ?> <div class="alert alert-error"> <?php foreach ($form->errors() as $key => $errors): ?> <div><?= implode('<br>', $errors) ?></div> <?php endforeach ?> </div> <?php endif ?>
// site/controllers/my-page.php use Jevets\Kirby\Form; return function ($kirby) { // Initialize the Form $form = new Form([ 'name' => [ 'rules' => ['required'], 'message' => ['Name is required'] ], 'phone' => [], ]); // Process the form on POST requests if ($kirby->request()->is('POST')) { if ($form->validates()) { // Show a thanks page } else { // Redirect back to the GET form go('/my-page'); } } return compact('form'); };
Contributing
Feel free to send a pull request!
Issues/Bugs
Please use the GitHub issue tracker.
mzur/kirby-form 适用场景与选型建议
mzur/kirby-form 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 74.44k 次下载、GitHub Stars 达 8, 最近一次更新时间为 2017 年 01 月 26 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「form」 「kirby」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 mzur/kirby-form 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 mzur/kirby-form 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 mzur/kirby-form 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
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.
Zero-dependency global `kirbylog()` helper for any content
Courier offers a convenient and painless solution for creating emails tailored for your Kirby website.
A Laravel Filament Forms slug field.
Blade template for Kirby
Search Kirby with Loupe
统计信息
- 总下载量: 74.44k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 8
- 点击次数: 18
- 依赖项目数: 1
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2017-01-26