silverstripe/contact-form
Composer 安装命令:
composer require silverstripe/contact-form
包简介
Allows you to create a contact form in SilverStripe with optional Postmark integration. Works with Bootstrap Forms module.
README 文档
README
This module allows you to create a simple contact form to add to a page type. It is highly configurable since the creation of the form happens in the page controller.
Features
- Integrates with Postmark for bullet-proof email delivery
- Integrates with the Boostrap Forms module
- Includes an API for automatic jQuery validation
- A spam protection API that can be extended with your own spam protection plugins
- Logs failed spam attempts to the database, and locks out repeat offending IPs
The "Kitchen Sink" example
<?php public function ContactForm() { return ContactForm::create("ContactForm","you@example.com","You've received a new contact form!") ->addFields( TextField::create("Name","What is your name?"), EmailField::create("Email", "What is your email?") ) // You can add fields as strings, too. ->addField("Your message//Textarea") ->setSuccessMessage("Thanks for submitting the form!") ->setSuccessURL($this->Link('success')) ->setOnBeforeSend(function($data, $form) { // Do stuff here. Return false to refuse the form. }) ->setEmailTemplate("MyCustomTemplate") ->addOmittedField("SomeField") ->setIntroText("Someone submitted a form. Here's the data.") ->addSpamProtector( SimpleQuestionSpamProtector::create() ->addQuestion("What's the opposite of skinny?","fat") ->addQuestion("Which is bigger, a lake or an ocean?","ocean") ) ->render(); }
What's with ->render()?
The ContactForm class is not actually a form. It is an object that serves as a proxy manager of a Form object. The ->render() method is critical to send the form to the template.
ContactFormPage
The ContactForm module comes with a page type that allows you to easily create contact forms based on user input in the CMS. The ContactFormPage class has fields for the "To" address, success messaging, and more.
To create a page with a contact form, simply create a descendant of ContactFormPage and call the parent Form() method.
<?php class MyContactPage extends ContactFormPage {} class MyContactPage_Controller extends ContactFormPage_Controller { public function Form() { return parent::Form() ->addFields( TextField::create("YourName","Your name"), EmailField::create("Email","Your email"), TextareaField::create("Message","Your message") ) ->render(); } }
Setting up Postmark
Simply add your API key and confirmed "from" address to your _config.php.
<?php define('POSTMARKAPP_API_KEY','xxxxxxxxxxxxxxxxxxxxx'); define('POSTMARKAPP_MAIL_FROM_ADDRESS', 'me@example.com');
Once these settings are in place, the ContactForm module will use Postmark as its delivery method.
Integrating with Bootstrap Forms
If you have the BootstrapForms module installed, the form will automatically render as a BootstrapForm, unless you tell it otherwise, using ->setUseBootstrap(false)
Setting the default spam protection
You can set up default spam protection that every form will use, unless configured otherwise.
_config.php
<?php ContactForm::set_default_spam_protection(array( SimpleQuestionSpamProtector::create() ->setHeading("Prove you're human by answering a simple question") ->addQuestion("Is fire hot or cold?", "hot") ->addQuestion("What color is a stop sign?", "red") ->addQuestion("Is water wet or dry?","wet") ->addQuestion("Is the world flat?", "no") ->addQuestion("What animal says \"Meow?\"", "cat"), HoneyPotSpamProtector::create() ->setName("PleaseFillThisOutYouBot")
silverstripe/contact-form 适用场景与选型建议
silverstripe/contact-form 是一款 基于 JavaScript 开发的 Composer 扩展包,目前已累计 1.78k 次下载、GitHub Stars 达 11, 最近一次更新时间为 2013 年 01 月 31 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「form」 「email」 「Forms」 「contact」 「postmark」 「silverstripe」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 silverstripe/contact-form 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 silverstripe/contact-form 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 silverstripe/contact-form 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
ConfirmationField is a form field for Atk14 applications. It's like the BooleanField (checkbox) but the ConfirmationField must be ticked.
Field for number with restricted count of digits and decimal places
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.
HTML and form generation
Build forms from schema
A Laravel Filament Forms slug field.
统计信息
- 总下载量: 1.78k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 12
- 点击次数: 21
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: BSD-3-Clause
- 更新时间: 2013-01-31