How To: Create a Form

This article illustrates how to create a form containing an item view and a list view. Forms contain one or more views and other controls that comprise the user interface you see when opened in a browser. Forms have rules that control the behavior of the form, for example, starting a workflow after you click a button.

The Leave Request Form you create
Leave Request Form

Scenario

Continuing with the Leave Request application, you need a form that acts as the user interface for entering and approving leave requests. The form contains the leave item view with the leave details, and the leave list view that displays saved leave requests. You created these views by following the steps in the topic How To: Create an Item View and a List View.

Steps

You generate a form from the Leave Request Item View, then add the list view. By generating the form, K2 creates the form and adds the item view to the form's canvas. You could also design a form which creates the form with an empty canvas. In that case you manually add the views you need.

  1. Generate a form from the Leave Request Item View. Name the form Leave Request Form. Change the view title to Leave Details.
    1. In K2 Designer, right-click the Leave Request Item View and select Generate Forms.
    2. Change the form name to
      Leave Request Form,
      then select the option to Save and edit the Form. Click OK.
      Generate Form
    3. Your design canvas should look similar to the image below. (Depending on your K2 version, your form may have a different style and color.)
      Generate a Form

    4. Click (Enter View Title) and change it to
      Leave Details.
      This step is not required, but your form sections are more clear with descriptive titles.
      Change View Title
  2. Add the Leave Request List View to the design canvas, just below the item view. Change the view title to All Leave Requests.
    1. Now, you add the second view to the design canvas. On the left-side of your screen, make sure the Views tab is active. Locate the Leave Request List View in the Recent Items category. (Your explorer may not match the image below exactly.) Click and drag the view onto the design canvas. Notice as you drag the view onto the canvas, placeholders appear. Drop the view into the placeholder just below the Leave Details view.
      Drag View Onto Canvas
    2. Change the view title to
      All Leave Requests.
      Change View Title
    3. Your design canvas should look similar to the image below.
      Leave Request Form

  3. Change the theme to Grey Void.

    Before moving on to the workflow build, you change the form's theme. A theme is a template that controls the look and feel of the form. There are a number of themes you can choose from or you can create your own.

    1. Click anywhere on the form's canvas that is not part of a view. Locate the Theme property in the Properties pane on the right-side of your screen. Change the Theme to Grey Void.
      Change Theme
    2. Your form should look like the image below. Click Finish to save and exit your form.
      Grey Void Theme
Review

A form is the user interface you see when you open itin a browser. Forms are containers for views, other controls, and rules. A single form may have one or more views that typically create logical sections for interacting with data. You can apply individual controls to a form as well, such as buttons or images. Form rules control the behavior of the form, for example, starting a workflow after you click a button.

Next: How To: Create a Workflow