Skip to end of metadata
Go to start of metadata

This page guides you how to implement radio button editor in form builder. The radio button editor provides a way for users to choose an option in a defined group. By default all radio buttons in a section will be automatically grouped together, allowing you to select only a single item at a time. If you are new to form builder, please see Form Builder Overview.

On this page:

Preparing Form Metadata

In order to use the form builder, first you need to create a form metadata that are based on a particular model class. To get more insight about form metadata, you can refer to Understanding Form Metadata. The radio button editor should map to a boolean property which indicates the value of the radio button. When users select a radio button, the bound property will be set to true. Consequently, the other properties will be set to false automatically.

Consider that you have a domain model class for Person such as shown below.

Person.cs

 

Then, create a form definition for the Person class, create a new class called PersonFormMetadata.cs with the metadata definition shown below.

PersonFormMetadata.cs

Preparing ViewModel

Once you have created the form metadata class for a model, the next step is to create a ViewModel class that provides user interaction logic for editing-related tasks. Derive your view model from EditorViewModelBase(T) Class. You also need to specify the form metadata type directly in the editor view model. See the following example.

PersonEditorViewModel.cs

Preparing View for iOS

In iOS, UIFormViewController will be used to simplify the form construction. You only need to specify the previously created view model in there and you will get the form builder running perfectly in iOS. For complete explanation, you can refer to Understanding iOS Form Builder.

PersonEditorViewController.cs

The results can be seen in the following image.

Preparing View for Android

In Android, FormActivity will be used to simplify the form construction. You only need to specify the previously created view model in there and you will get the form builder running perfectly in Android. For complete explanation, you can refer to Understanding Android Form Builder.

PersonEditorActivity.cs

The results can be seen in the following image.