【问题标题】:template forms in prismic棱镜中的模板形式
【发布时间】:2019-01-25 15:05:45
【问题描述】:

我是 prismic 的新手,并试图弄清楚这是否是我需要的正确工具。我需要创建多个表单模板。我希望棱镜用户能够构建模板,该模板将加载到 gatsby 中,其中每个字段将根据标题、类型、操作、名称构建为组件。

  • 标题将是标题或标签。
  • type 将是表单元素的类型,例如:输入、按钮、单选操作,
  • 如果它是一个按钮,它需要执行的操作。
  • 为表单元素命名。

棱镜似乎是一个很好的候选者,有没有人知道我如何设置棱镜端的任何例子。到目前为止,我看到的大部分内容都是只有标题和图像的整页。不完全是形式。

在他们的存储库中,我只看到这些创建元素的选项我错过了一些重要的选项吗?

  • 标题
  • 富文本
  • 图片
  • 内容关系
  • 链接
  • 媒体链接
  • 日期
  • 时间戳
  • 颜色
  • 号码
  • 关键文本
  • 选择
  • 嵌入
  • 地理点

我将如何创建表单元素,有没有办法创建自定义对象以导出?每次我尝试向它说的 json 编辑器添加新的文件或自定义对象时。无法识别,属性将被忽略。 我希望能够使用该组将一堆表单元素组合在一起,即使它们只是我可以将自定义属性传递给的自定义对象,所以当我将组加载到 React 中时,我可以使用自定义属性来构建我的组件??如果可以使用棱镜,任何人都可以让我直接在这里。

谢谢!

【问题讨论】:

    标签: prismic.io


    【解决方案1】:

    我不能说 Prismic 是否是这项特定工作的最佳工具,但我认为您高估了渲染 html 表单所需的确切内容。

    考虑以下自定义类型。它实际上只包含标题、结构化文本、可重复区域和选择。您如何处理这些数据完全取决于您在前端。

    {
      "Main": {
        "uid": {
          "type": "UID",
          "config": {
            "label": "Form UID",
            "placeholder": "Form UID"
          }
        },
        "form_title": {
          "type": "StructuredText",
          "config": {
            "single": "heading2",
            "label": "Form Title",
            "placeholder": "Form Title"
          }
        },
        "action_title": {
          "type": "StructuredText",
          "config": {
            "single": "heading2",
            "label": "action title",
            "placeholder": "Submit form"
          }
        },
        "form_action_description": {
          "type": "StructuredText",
          "config": {
            "single": "paragraph",
            "label": "form action description",
            "placeholder": "form action description"
          }
        },
        "success_message": {
          "type": "StructuredText",
          "config": {
            "single": "paragraph",
            "label": "success message",
            "placeholder": "success message"
          }
        },
        "error_message": {
          "type": "StructuredText",
          "config": {
            "single": "paragraph",
            "label": "error message",
            "placeholder": "error message"
          }
        },
        "submit_button_text": {
          "type": "StructuredText",
          "config": {
            "single": "paragraph",
            "label": "submit button text",
            "placeholder": "submit"
          }
        },
        "body": {
          "type": "Slices",
          "fieldset": "Slice zone",
          "config": {
            "choices": {
              "test": {
                "type": "Slice",
                "fieldset": "Form Section",
                "description": "Section of a form",
                "icon": "vertical_align_center",
                "display": "list",
                "non-repeat": {
                  "form_section_title": {
                    "type": "StructuredText",
                    "config": {
                      "single": "heading1",
                      "label": "Form Section title",
                      "placeholder": "Form Section title"
                    }
                  },
                  "form_section_description": {
                    "type": "StructuredText",
                    "config": {
                      "single": "paragraph",
                      "label": "Form Section Description",
                      "placeholder": "Form Section Description"
                    }
                  }
                },
                "repeat": {
                  "label": {
                    "type": "StructuredText",
                    "config": {
                      "single": "paragraph",
                      "label": "label",
                      "placeholder": "label"
                    }
                  },
                  "type": {
                    "type": "Select",
                    "config": {
                      "options": [
                        "text",
                        "textarea",
                        "checkbox",
                        "radio",
                        "submit"
                      ],
                      "default_value": "text",
                      "label": "type"
                    }
                  },
                  "name": {
                    "type": "StructuredText",
                    "config": {
                      "single": "paragraph",
                      "label": "name",
                      "placeholder": "name"
                    }
                  }
                }
              }
            }
          }
        }
      }
    }

    【讨论】:

      猜你喜欢
      • 2018-10-25
      • 1970-01-01
      • 2019-10-12
      • 2017-05-04
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-10-24
      相关资源
      最近更新 更多