Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Angelo 111 posts 260 karma points
    Sep 24, 2018 @ 15:56
    Angelo
    0

    create a form programmatically

    is it possible to create a form programmatically?

    thank you

    Angelo

  • Nicholas Westby 2054 posts 7103 karma points c-trib
    Sep 24, 2018 @ 17:51
    Nicholas Westby
    1

    In a way, yes.

    The default persistence implementation stores forms as JSON files, and the default location is ~/App_Data/Formulate/Json/. The format is pretty straightforward. Here's an example of a form JSON file:

    {
      "Id": "a6afd8c3-570f-4894-a6c7-fba09a2cc050",
      "Path": [
        "3d634e15-7d15-45fa-a8a9-12838fa3a345",
        "a6afd8c3-570f-4894-a6c7-fba09a2cc050"
      ],
      "Alias": null,
      "Name": "Contact",
      "Fields": [
        {
          "Id": "7a1b92f7-fdae-486c-9fa8-b56e86b838fe",
          "Alias": null,
          "Name": "State of Residence (Extended)",
          "Label": "State of Residence:",
          "Category": null,
          "Validations": [],
          "MetaInfo": null,
          "FieldConfiguration": "{\r\n  \"dataValue\": \"937f4690697b4505b16030cf2584cb46\"\r\n}",
          "TypeId": "8b277af3-1b1f-4698-97d2-3900c6621c7d",
          "IsTransitory": false,
          "IsServerSideOnly": false,
          "IsHidden": false,
          "IsStored": true
        }
      ],
      "Handlers": [
        {
          "Id": "929bdfac-ee13-4401-9b70-9a9bc5bce913",
          "Alias": null,
          "Name": null,
          "Enabled": false,
          "HandlerConfiguration": "{}",
          "TypeId": "238ea920-71f4-4d8c-9cc4-33d7181c9c46"
        }
      ],
      "MetaInfo": null
    }
    

    There are other JSON files too (e.g., for validations, layouts, and so on). Maybe create what you're looking for manually, and then you can work out how to serialize similar JSON from there.

    I'm happy to answer any questions you may have as well.

  • Angelo 111 posts 260 karma points
    Sep 24, 2018 @ 18:01
    Angelo
    0

    Hello Nicholas ...that is great :)

    sometimes there are those usual forms like newsletter and contact us etc and this is handy because we only have to create a helper with this json and it stays included in your plugin with no need for configuration :) ...perfect

    thank you a lot for your answer !

    Angelo

  • Nicholas Westby 2054 posts 7103 karma points c-trib
    Sep 24, 2018 @ 18:04
    Nicholas Westby
    0

    Cool. In that case, you don't even need to do JSON serialization. You could just have the plugin drop the files in the file system (which you could create manually in advance in the Formulate section of the Umbraco back office).

Please Sign in or register to post replies

Write your reply to:

Draft