定制 crazycat/module-magento2-forms 二次开发

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

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

crazycat/module-magento2-forms

Composer 安装命令:

composer require crazycat/module-magento2-forms

包简介

Customized forms management for Magento 2

README 文档

README

Help to create and handle customized forms, show as widgets.

Administrator will receive an email after customer submitting a form, and is able to check submit records through CONTENT / Forms / Post Records in admin panel.

Installation

  1. Execute this command to download the module through composer:
    composer require crazycat/module-magento2-forms

  2. Execute these commands to enable the modules:
    php bin/magento module:enable CrazyCat_Base
    php bin/magento module:enable CrazyCat_Forms

  3. Execute these commands to update database, recompile and flush cache:
    php bin/magento setup:upgrade
    php bin/magento setup:di:compile
    php bin/magento cache:flush

How to use

Create a Form

  1. Create a template file under CrazyCat_Forms folder of theme directory, for example: [root]/app/design/frontend/[Vendor]/[theme]/CrazyCat_Forms/templates/forms/inquiry.phtml

  2. Create a form through admin panel: CONTENT / Forms / Forms > Add New Form

    • Form Name - Form name to show in form list, post record list and widget management
    • Identifier - Unique key of the form
    • Email Sender - To select a sender from the list of which options are same with store config email identities
    • Recipients - Recipients emails, separated by comma
    • Renderer - To render elements through customize a template or configure elements
    • Template - Template path like CrazyCat_Forms::forms/inquiry.phtml
    • Elements - Configure elements
  3. Create a Form widget through widget management or insert one through WYSIWYG editor to show in storefront

Form Template

Here is an example of email template:

<?php
use CrazyCat\Forms\Block\Widget\Form;

/** @var Form $block */
$blockId = $block->getJsId();
?>
<form method="post"
      action="<?= $block->escapeUrl($block->getFormAction()) ?>"
      data-mage-init='{"validation": {}}'>
    <?= $block->getHiddenInputHtml(); /* @noEscape */ ?>
    <fieldset class="fieldset">
        <div class="field required">
            <label for="<?= $blockId /* @noEscape */ ?>-firstname" class="label">
                <?= $block->escapeHtml(__('Firstname')) ?>
            </label>
            <div class="control">
                <input id="<?= $blockId /* @noEscape */ ?>-firstname" type="text" name="data[Firstname]"
                       class="input-text required-entry"/>
            </div>
        </div>
        <div class="field required">
            <label for="<?= $blockId /* @noEscape */ ?>-lastname" class="label">
                <?= $block->escapeHtml(__('Lastname')) ?>
            </label>
            <div class="control">
                <input id="<?= $blockId /* @noEscape */ ?>-lastname" type="text" name="data[Lastname]"
                       class="input-text required-entry"/>
            </div>
        </div>
        <div class="field required">
            <label for="<?= $blockId /* @noEscape */ ?>-email" class="label">
                <?= $block->escapeHtml(__('Email')) ?>
            </label>
            <div class="control">
                <input id="<?= $blockId /* @noEscape */ ?>-email" type="text" name="data[Email]"
                       class="input-text required-entry validate-email"/>
            </div>
        </div>
    </fieldset>
    <div class="actions-toolbar">
        <button type="submit" class="action primary">
            <span><?= $block->escapeHtml(__('Submit')) ?></span>
        </button>
    </div>
</form>

Several key points need to be noted:

  • Form method must be post
  • Form action must be $block->escapeUrl($block->getFormAction())
  • Hidden fields are required: $block->getHiddenInputHtml()
  • Name of post elements must be wrapped with data[]

Form Elements

Using Configure Elements as renderer means that elements in the block will be rendered with UI components.

The element management is a drag and drop box, it provides some common types of frontend model and validation to choose.

Configuration column of the elements is to add JavaScript settings for related UI component.

CAPTCHA

Administrator is able to enable the CAPTCHA through switching this setting in admin panel:
STORES / Settings / Configuration > SECURITY / Google reCAPTCHA Storefront > Storefront / Enable for Customized Forms

And fill in Google API Website Key and Google API Secret Key of the related service.

crazycat/module-magento2-forms 适用场景与选型建议

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

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

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

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

BUG 修复 & 性能优化

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

项目外包 & 长期维护

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

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

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: OSL-3.0
  • 更新时间: 2021-10-02