定制 robuust/craft-formdesk 二次开发

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

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

robuust/craft-formdesk

最新稳定版本:2.1.2

Composer 安装命令:

composer require robuust/craft-formdesk

包简介

Formdesk forms for Craft 4

README 文档

README

Plugin that allows you to display Formdesk forms

Requirements

This plugin requires Craft CMS 4.0.0 or later.

Installation

To install the plugin, follow these instructions.

  1. Open your terminal and go to your Craft project:

     cd /path/to/project
    
  2. Then tell Composer to load the plugin:

     composer require robuust/craft-formdesk
    
  3. In the Control Panel, go to Settings → Plugins and click the “Install” button for Formdesk.

Config

Create a file called formdesk.php in you Craft config folder with the following contents:

<?php

return [
    // General
    'host' => 'YOUR_HOST',
    'apiKey' => 'YOUR_API_KEY',
];

Usage

Create a new "Formdesk" field and add it to the desired element's field layout. Now when editing such element you can select a Formdesk list to use.

In your front-end templates you can render this Formdesk list as a form.

Example

Here is an example that renders a Formdesk form. You can change and style this example any way you want.

  {% if errors is defined %}
    <p>{{ errors.message|t }}</p>
  {% endif %}
  <form method="post">
    {{ csrfInput() }}
    {{ actionInput('formdesk/submit') }}
    {{ redirectInput('url_to_redirect_to') }}
    {% for field in entry.form %}
      {% switch field.type %}
        {% case 'radio' or 'checkbox' %}
          {% for option in field.options %}
            <input id="{{ field.id }}-{{ loop.index }}" name="{{ field.name }}{% if field.type == 'checkbox' %}[]{% endif %}" type="{{ field.type }}" {% if field.required %} required{% endif %} value="{{ option.value }}" /> <label for="{{ field.id }}-{{ loop.index }}">{{ option.text }}</label>
          {% endfor %}
        {% default %}
          <input id="{{ field.id }}" name="{{ field.name }}" type="{{ field.type }}" placeholder="{{ field.label }}"{% if field.required %} required{% endif %} value="{{ field.value }}" />
      {% endswitch %}
      <br />
    {% endfor %}
    <input type="submit" />
  </form>

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2022-05-18