1

I'm new to prismic and trying to figure out if this is right tool for what I need. I need to create multiple form templates. I want prismic user to be able to build out the template, which will get loaded into gatsby where each field will get built out as components based on a title, type, action, name.

  • Title will be the title or label.
  • type will be the type of form element, ex: input, button, radio action,
  • if its a button the action it needs to do.
  • name the name for the form element.

Does prismic seem like a good candidate for this and does anyone know of any examples of how I might go about setting up the prismic end. Most of what Ive seen so far is full pages with just title and images. Not exactly forms.

In their repository I only see these options to create elements am I missing some important ones ?

  • Title
  • Rich Text
  • Image
  • Content Relationship
  • Link
  • Link to Media
  • Date
  • Timestamp
  • color
  • number
  • key text
  • Select
  • Embed
  • GeoPoint
  • Group

How would I go about creating form elements, Is there a way to create custom objects to export? Every time I try to add a new filed or a custom object to the json editor it says. Unrecognized, property it will be ignored. I'd like to be able to use the group to group a bunch of form elements together even if they are just custom objects that I can pass custom properties to so when I load the group into React I can use the custom properties to build out my components ?? Can anyone set me straight here on if this is possible using prismic.

Thanks!

4

1 回答 1

0

我不能说 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-12-20T16:32:19.877 回答