定制 am-impact/amforms 二次开发

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

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

am-impact/amforms

Composer 安装命令:

composer require am-impact/amforms

包简介

Forms plugin for Craft

README 文档

README

Forms in Craft, made easy

CP functionality

When users have permission to access the plugin, they can do various stuff in the CP. There's an extra setting that'll allow users to control the plugin's settings.

Forms

You're able to activate submissions and / or notifications. This means you could choose to ignore the submissions if you want to, but only receive notifications when a form was submitted.

NewForm

Notifications are activated, and all information will be filled out by default. The Sender name and email addresses fields will automatically contain the information from your email settings in Craft's CP.

Notifications

The plugin will use it's own templates to display forms and email submissions. You have the option to override these templates in general or per form! Just create your own folder in the templates folder (e.g.: _amforms) and create a template that you would like to override. You can see the default template names in the placeholders, so if you create your own template with the same name, you could choose to make this your default templates for all your forms. When you create a template with a different name, you could create a template per form.

This tab is only available to admins.

Templates

Fields

When you install the plugin, you get some commonly used fields by default. The fields that are created are stored in a different context / scope than Craft's fields. This means that you're able to reuse these fields in any form and that they won't be shown in Craft's field list.

Fields

Export

You have the option to export your submissions per form. You'll be able to choose which fields you'd like to be included in your export (Matrix supported!). When you create an export, it'll start a task that export your submissions into a file located in your storage folder. When it's done, you're able to download the file or restart the export.

NewExport

ExportCriteria

ExportOverview

Settings

By default, the anti-spam is activated for your forms, but there's also an option to activate Google reCAPTCHA.

General

Exports

AntiSpam

reCAPTCHA

Display your forms

Simple tag

This will only display basic fields!

{{ craft.amForms.displayForm('formHandle') }}

Simple field tag

{% set form = craft.amForms.getForm('formHandle') %}

{{ form.displayField('fieldHandle') }}

Simple field tag (using a namespace)

{% set form = craft.amForms.getForm('formHandle') %}
<input type="hidden" name="namespace" value="{{ form.getNamespace() }}">

{{ form.displayField('fieldHandle') }}

Custom HTML

<form method="post" action="" accept-charset="UTF-8">
    {{ getCsrfInput() }}

    {# This should always be here! #}
    <input type="hidden" name="action" value="amForms/submissions/saveSubmission">

    {# Insert your form's handle. #}
    <input type="hidden" name="handle" value="formHandle">

    {# Optional: Redirect URL. Will redirect to current page by default. #}
    <input type="hidden" name="redirect" value="contact?message=thankyou">

    {# Optional: Anti-spam protection. #}
    {{ craft.amForms.displayAntispam() }}

    {# Optional: Google reCAPTCHA protection. #}
    {{ craft.amForms.displayRecaptcha() }}

    {# Place the HTML of your fields here #}

    <input type="submit" value="Submit">
</form>

Custom HTML with displayField

{% set form = craft.amForms.getForm('formHandle') %}

<form method="post" action="" accept-charset="UTF-8">
    {{ getCsrfInput() }}

    {# This should always be here! #}
    <input type="hidden" name="action" value="amForms/submissions/saveSubmission">

    {# Insert your form's handle. #}
    <input type="hidden" name="handle" value="{{ form.handle }}">

    {# This will namespace your inputs (for IDs and such), but it's not required though #}
    <input type="hidden" name="namespace" value="{{ form.getNamespace() }}">

    {# Optional: Anti-spam protection. #}
    {{ craft.amForms.displayAntispam() }}

    {# Optional: Google reCAPTCHA protection. #}
    {{ craft.amForms.displayRecaptcha() }}

    {# Place the HTML of your fields here #}
    {{ form.displayField('fieldHandle') }}
    {{ form.displayField('aFieldHandle') }}
    {{ form.displayField('anotherFieldHandle') }}

    <input type="submit" value="Submit">
</form>

Custom field HTML

Change formHandle to your form's handle.

<div class="field">
    <label for="frm_comment">Comment</label>
    <input type="text" id="frm_comment" name="fields[comment]" value="{% if formHandle.comment is defined %}{{ formHandle.comment }}{% endif %}">
    {% if formHandle is defined %}
        {{ errorList(formHandle.getErrors('comment')) }}
    {% endif %}
</div>

Custom Matrix field

<div class="field">
    {#
        Notify Craft which Matrix block (handle) will be inserted.

        Our field name for this example is: Persons
        Our block name for this example is: Person
    #}
    <input type="hidden" name="fields[persons][new1][type]" value="person">

    {# Block fields #}
    <label for="frm_firstname">First name</label>
    <input type="text" id="frm_firstname" name="fields[persons][new1][fields][firstName]">
    <label for="frm_lastname">Last name</label>
    <input type="text" id="frm_lastname" name="fields[persons][new1][fields][lastName]">
    {% if formHandle is defined %}
        {{ errorList(formHandle.getErrors('persons')) }}
    {% endif %}
</div>

Errorlist macro

{% macro errorList(errors) %}
    {% if errors %}
        <ul class="errors">
            {% for error in errors %}
                <li>{{ error }}</li>
            {% endfor %}
        </ul>
    {% endif %}
{% endmacro %}

If you want to include it on the template itself, use:

{% from _self import errorList %}

Dashboard widget

Display your recent submissions on your dashboard.

WidgetSettings

WidgetSmall

WidgetBig

am-impact/amforms 适用场景与选型建议

am-impact/amforms 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 2.61k 次下载、GitHub Stars 达 120, 最近一次更新时间为 2015 年 07 月 20 日, 在 PHP 生态内属于活跃度较高的组件。

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

围绕 am-impact/amforms 我们能提供哪些服务?
定制开发 / 二次开发

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

BUG 修复 & 性能优化

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

项目外包 & 长期维护

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

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

统计信息

  • 总下载量: 2.61k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 120
  • 点击次数: 10
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 120
  • Watchers: 14
  • Forks: 21
  • 开发语言: PHP

其他信息

  • 授权协议: Unknown
  • 更新时间: 2015-07-20