Form

Extends Nothing
Namespace Limbo.Forms.Models

The Form class is the main model in this package, as describes the form it self along with the fields that make up the form.

As we're typically using the package in a SPA like context, it's also possible to specify and endpoint URL to which the form should be submitted.

Properties

The class has the following properties:

C# Name C# Type JSON Name Description
Title string title An optional title of the form.
Url string Url The URL of the page where the form is shown.
EndpointUrl string endpointUrl The URL for the underlying API to receive the form postback.
Description string description The fields making up the form.

Usage

A new instance of the Form class can be initialized like in the example below:

@using Limbo.Forms.Models
@using Limbo.Forms.Models.Fields
@{

    // Initialize a new form
    Form form = new Form {
        Title = "This is my form",
        Url = "/my-page/",
        EndpointUrl = "/api/form",
        Fields = new List<FieldBase>()
    };

}

JSON Output

By default, when serializing the form model to JSON, the output will look like:

{
  "title": "This is my form",
  "url": "/my-page/",
  "endpointUrl": "/api/form",
  "fields": []
}

Properties in the C# model that is null will be omitted in the JSON output.