# Customize autogenerated fields

You can customize the automatically generated fields by using the following predefined attributes:

## DefaultValue

The `DefaultValue` attribute determines the predefined value that is displayed when the widget editor opens initially. The user can overwrite it afterwards.

To apply this attribute, use the following code sample:

```C#
using System.ComponentModel;
using Progress.Sitefinity.Renderer.Entities.Content;
using Progress.Sitefinity.Renderer.Designers.Attributes;

namespace SitefinityWebApp
{
   public class DemoDefaultValue
   {
     [DefaultValue("London")]
     public string City { get; set; }
   }
}
```

## DisplayName

If you add this attribute to a property of the widget, the property title is displayed according to the specified value.

To apply this attribute, use the following code sample:

```C#
using System.ComponentModel;
using Progress.Sitefinity.Renderer.Entities.Content;
using Progress.Sitefinity.Renderer.Designers.Attributes;

namespace SitefinityWebApp
{
   public class DemoDisplayNameAttribute
   {
       [DisplayName("CSS class")]
       string CssClass { set; get; }
   }
}
```

## Description

This attribute serves as instructional text for the field. It provides instructional text to clarify the usage of the field.

The description looks in the following way:

To apply this attribute, use the following code sample:

```C#
using System.ComponentModel;
using Progress.Sitefinity.Renderer.Entities.Content;
using Progress.Sitefinity.Renderer.Designers.Attributes;

namespace SitefinityWebApp
{
   public class DemoDescription
   {
       [Description("This is the description")]
       public string DescriptionProp { get; set; }
   }
}
```

## DescriptionExtended

This attribute inherits the `Description` attribute and adds two additional properties to provide additional UI elements for enhancing the field visualization – `InlineDescription` and `InstructionalNotes`.

The attribute looks in the following way:

![description-extended](https://www.progress.com/documentation/sitefinity-cms/assets/5a39fbead3495b0b33eb33a2a542d2f9/description-extendedcec740b42bbc6d27ad54ff0300e02f5f.png "description-extended")

To apply this attribute, use the following code sample:

```C#
using System.ComponentModel;
using Progress.Sitefinity.Renderer.Entities.Content;
using Progress.Sitefinity.Renderer.Designers.Attributes;

namespace SitefinityWebApp
{
   public class DemoDescriptionExtended
   {
     [DescriptionExtended("This is the extended description", InlineDescription = "Inline description", InstructionalNotes = "Instructional notes")]
     public string DescriptionExtendedProp { get; set; }
   }
}
```

## Placeholder

This attribute specifies a placeholder text in the input field. You can use it to visualize a predefined text in the input field that will be overwritten by the user. It is valid for fields of type `string` only.

The attribute looks in the following way:

![placeholder](https://www.progress.com/documentation/sitefinity-cms/assets/66773e6b7f164812257aea69f3a8d11d/placeholderfbc740b42bbc6d27ad54ff0300e02f5f.png "placeholder")

To add this attribute, use the following code:

```C#
using System.ComponentModel;
using Progress.Sitefinity.Renderer.Entities.Content;
using Progress.Sitefinity.Renderer.Designers.Attributes;

namespace SitefinityWebApp
{
 public class DemoPlaceholder
 {
   [Placeholder("This is the placeholder")]
   public string PlaceHolderProp { get; set; }
 }
}
```

## Mirror

This attribute sets a field that mirrors its value from another field. For example, the page title for search engines is mirrored from the page title and it can be later overwritten. It is valid for fields of type `string` only.

The attribute looks in the following way:

![mirror-field](https://www.progress.com/documentation/sitefinity-cms/assets/dbe45e53d101c519792c5760319b7a05/mirror-field17c840b42bbc6d27ad54ff0300e02f5f.gif "mirror-field")

To add this attribute, use the following code:

```C#
using System.ComponentModel;
using Progress.Sitefinity.Renderer.Entities.Content;
using Progress.Sitefinity.Renderer.Designers.Attributes;

namespace SitefinityWebApp
{
   public class DemoMirror
   {
     public string PlainString { get; set; }
     [Mirror(nameof(AllPropertiesModel.PlainString))]
     public string MirroredField { get; set; }
   }
}
```

## Browsable

If you add this attribute to a property of the widget, the property is not displayed in the property editor, and it will not be persisted in the database. This property becomes hidden.

To add the attribute, use the following code:

```C#
using System.ComponentModel;
using Progress.Sitefinity.Renderer.Entities.Content;
using Progress.Sitefinity.Renderer.Designers.Attributes;

namespace SitefinityWebApp
{
   public class DemoBrowsable
   {
     [Browsable(false)]
     IList<NodeViewModel> Nodes { get; }
   }
}
```

## TableView

This attribute is valid for complex objects. It controls whether to render the complex object inline as a table or as a section. You can also use it with lists of complex or primitive properties to modify the way the table looks like. For more information >> Lists.

By using this attribute, you can:

* Control whether the table rows can be reordered by drag-and-drop
* Control whether a single or multiple table rows can be selected by default
* Control whether many rows can be added at once either from selecting a predefined list or by entering values manually.
* Control the number of columns that are displayed when rendering lists of complex or primitive properties. The rest of the columns will be accessible through a separate page using the *More details* button

### Complex object as a table view

The attribute makes a complex object look in the following way:

![complex-object-table](https://www.progress.com/documentation/sitefinity-cms/assets/d32abd2e42ef1694d3ee8756e0b439c0/complex-object-table.png "complex-object-table")

### Reorderable table view with selectable rows and Add many options

You can use the table view with lists of complex or primitive properties to make table rows selectable and reorderable.

The table looks in the following way:

![CoreTable](https://www.progress.com/documentation/sitefinity-cms/assets/0d909e3eafd4e7fb04e17aba542cc0c0/coretable.png "CoreTable")

### Add many option

You can add *Add many* button. It is used to add a longer list at bulk. You can also use a set of predefined list that you can find useful, such as *Timezones* or *Countries*.

The option looks in the following way:

![CoreAddMany](https://www.progress.com/documentation/sitefinity-cms/assets/ba38dcbf2a2677fd12b2c3802ee3f4c7/coreaddmany.png "CoreAddMany")

To add the table view attribute, use the following code:

```C#
using System.ComponentModel;
using Progress.Sitefinity.Renderer.Designers.Attributes;
using System.Collections.Generic;

namespace SitefinityWebApp
{
   public class DemoTableView
   {
       [TableView("TableTitle")]
       public ComplexObject ComplexTable { get; set; }

       [TableView(Reorderable = true, Selectable = true, MultipleSelect = true, ColumnCount = 3, AddManyFileName = "predefined_lists.json")]
       public IList<ComplexObject> ListTableView { get; set; }
   }

   public class ComplexObject
   {
       [DisplayName("First prop")]
       [DefaultValue("first")]
       [ContentSection(2)]
       public string FirstString { get; set; }

       [DisplayName("Second prop")]
       [DefaultValue("second")]
       [ContentSection(3)]
       public string SecondString { get; set; }

       [DisplayName("Third prop")]
       [DefaultValue("third")]
       [ContentSection(4)]
       public string ThirdString { get; set; }

       [DisplayName("Int prop")]
       [DefaultValue(42)]
       [ContentSection(1)]
       public int ChildInt { get; set; }
   }
}
```

> info **NOTE**: In the above sample:
>
> * `ColumnCount` is the number of columns that are displayed in the table, the rest are collapsed and can be viewed by clicking *More details*.
> * `ContentSection(<number>)` is the order in which the properties are displayed in  the table. For example, `ContentSection(1)` displays the property in the first column.

You can provide predefined lists with values in a `JSON` file. You place the file in one of the following:

* In the root folder - `wwwroot/js/{widget_name}/{file_name}.json`
* As embedded resource – `Scripts/{widget_name}/{file_name}.json`

The file must have the following structure:

```JSON
{
 "Predefined list 1": [
   "value 1",
   "value 2"
 ],
 "Predefined list 2": [
   "value 1",
   "value 2",
   "value 3"
 ]
}
```

> info **NOTE**: For a list of complex objects, *Add many* inserts only one value per row, into the property that is displayed in the first column (`ContentSection(1)`). It does not populate the other properties of the complex object. Those remain set to their own `DefaultValue` and must be edited per row, or through *More details*, after the rows are added.

### Add many with a list of primitive values

You can also apply `AddManyFileName` directly to a list of primitive values, such as `IList<string>`, instead of a list of complex objects. In this case, every value from the chosen predefined list is inserted as a new row, since there is only one column:

```C#
[TableView(Reorderable = true, Selectable = true, MultipleSelect = true, AddManyFileName = "predefined_lists.json")]
public IList<string> List { get; set; }
```

It uses the same `predefined_lists.json` structure described above.

### Prefill a list of complex objects with all properties set

To have every property of every row already populated when the widget editor opens, apply the `DefaultValue` attribute on the list property itself, using a JSON array of complete objects, in addition to `TableView` and `AddManyFileName`:

```C#
[TableView(Reorderable = true, Selectable = true, MultipleSelect = true, ColumnCount = 3, AddManyFileName = "predefined_lists.json")]
[DefaultValue("[{\"FirstString\":\"first\",\"SecondString\":\"second\",\"ThirdString\":\"third\",\"ChildInt\":42},{\"FirstString\":\"first2\",\"SecondString\":\"second2\",\"ThirdString\":\"third2\",\"ChildInt\":43}]")]
public IList<ComplexObject> ListTableView { get; set; }
```

## DataType

This attribute controls the visualization of the field.

You can use it in the following ways:

### HTML editor

Use the `DataType` attribute to display a `string` field type as an HTML editor.

The HTML field looks in the following way:

![html-field](https://www.progress.com/documentation/sitefinity-cms/assets/0e71f5f8644f6981b4303150604f3ff5/html-field63c840b42bbc6d27ad54ff0300e02f5f.png "html-field")

### Color picker

Use the `DataType` attribute to display a string field type as a color picker. You can combine the `DataType` and the `DefaultValue` attribute.

The color picker looks in the following way:

![color-field](https://www.progress.com/documentation/sitefinity-cms/assets/11482145af6a08c057c4e7670b17204a/color-field6cc840b42bbc6d27ad54ff0300e02f5f.png "color-field")

To configure the values of the color picker, use this [sample](https://github.com/Sitefinity/sitefinity-aspnetcore-mvc-samples/tree/master/src/color-palettes) on Sitefinity GitHub repository.

### Text area

Use the `DataType` attribute to display a `string` field type as a text area.

The text area field looks in the following way:

![CoreText](https://www.progress.com/documentation/sitefinity-cms/assets/3ca1273b5b26a5d7b02a50f775497ef5/coretext.png "CoreText")

### Checkbox

To display a Boolean field type as a checkbox, use the following code:

The checkbox looks in the following way:

![checkbox-field](https://www.progress.com/documentation/sitefinity-cms/assets/aa6ac2d0d87a8425cbbb4ab3a0bf84a1/checkbox-field73c840b42bbc6d27ad54ff0300e02f5f.png "checkbox-field")

### Radio button

Use this attribute to display a single option selector as a radio button. You use this attribute with the `enum` type.

The radio button looks in the following way:

![RadioButtonNetCore](https://www.progress.com/documentation/sitefinity-cms/assets/29378042895aaaa492df11c40e15c7b8/radiobuttonnetcore.png "RadioButtonNetCore")

### Chip selector with enum values

Use this attribute to display a single option selector values as a chip selector. You use this attribute with the `enum` type.

The chip selector with values looks in the following way:

![enum-chipchoice](https://www.progress.com/documentation/sitefinity-cms/assets/63438438faa06a5739adfe1c31445455/enum-chipchoice05c740b42bbc6d27ad54ff0300e02f5f.png "enum-chipchoice")

### Chip selector with int values

Use this attribute to display a single option selector integer values as a chip selector. You use this attribute with the `int` type.

The chip selector with numbers looks in the following way:

![IntChip](https://www.progress.com/documentation/sitefinity-cms/assets/84c64fdb4fe0d1ec8c1ecaa8e5a8e60a/intchip.png "IntChip")

### Dropdown

Use the attribute to display a single option selector as dropdown. You can either do this using an `enum` type or by utilizing the `ChoiceAttribute`.

The dropdown field looks in the following way:

![CoreDropdown](https://www.progress.com/documentation/sitefinity-cms/assets/319061b61ea2df0f381df845c97783ee/coredropdown.png "CoreDropdown")

### Password

Use the attribute to display a string field type as a password field.

The password field looks in the following way:

![CorePass](https://www.progress.com/documentation/sitefinity-cms/assets/a4dc31e1abf013ad8656a97c3cfdcc1d/corepass.png "CorePass")

### External data choice

You can populate a dropdown box or a list of choices dynamically from a custom data source, such as an external API. You can do this for single selection fields, such as dropdown box, or for multiple selection fields, such as checkbox.

You achieve this by creating an extensibility point in the ASP.NET Core Renderer.\
For more information, see *All properties widget sample* » [Extensibility](https://github.com/Sitefinity/sitefinity-aspnetcore-mvc-samples/tree/master/src/all-properties#extensibility) on Sitefinity GitHub Repository.

Dynamic choice fields look in the following way:

![Externaldatafiled](https://www.progress.com/documentation/sitefinity-cms/assets/870af19813387c1d48be7ef8306d1e45/externaldatafiled.jpg "Externaldatafiled")

### Range

Use the attribute to display a build in component for setting a range.

The range field looks in the following way:

![CoreRange](https://www.progress.com/documentation/sitefinity-cms/assets/142ea93342f0aa128d87607500f4a3c1/corerange.png "CoreRange")

### File types

Use the attribute to display a build in component for selecting allowed file types.

The field looks in the following way:

![CoreFiletypes](https://www.progress.com/documentation/sitefinity-cms/assets/23489e9d7800c864b5a12b4a7ed7a25f/corefiletypes.png "CoreFiletypes")

### Attributes

Use the attribute to display a build in component for creating and modeling attributes. The attributes are plain key-value pairs. This way, you can use the component for multiple purposes that can take advantage of such data structure.

The field looks in the following way:

![CoreAttributes](https://www.progress.com/documentation/sitefinity-cms/assets/f6734b2dc14d089b2ca60eba6457a767/coreattributes.png "CoreAttributes")

To apply the `DataType` attribute, use the following code sample:

````C#
using System.ComponentModel;
using Progress.Sitefinity.Renderer.Entities.Content;
using Progress.Sitefinity.Renderer.Designers.Attributes;

namespace SitefinityWebApp
{
   public class DemoDataType
   {
     //HTML field
     [DataType(customDataType: KnownFieldTypes.Html)]
     public string HtmlField { get; set; }
     
     //Color field
     [DefaultValue("#AABBCC")]
     [DataType(customDataType: KnownFieldTypes.Color)]
     public string ColorField { get; set; }
     
     //Text area
     [DataType(customDataType: KnownFieldTypes.TextArea)]
     public string TextAreaField { get; set; }

     //Checkbox field
     [DefaultValue(true)]
     [DataType(customDataType: KnownFieldTypes.CheckBox)]
     public bool CheckboxField { get; set; }
       
     //Radio button
     [DataType(customDataType: KnownFieldTypes.RadioChoice)]
     public EnumSingle EnumRadioChoice { get; set; }
     
     //Chip selector with enum vaues
     [DataType(customDataType: KnownFieldTypes.ChipChoice)]
     public EnumSingle EnumChipChoice { get; set; }
       
     //Chip selector with int vaues
     [DefaultValue(1)]
     [DisplayName("Integer as choice field")]
     [DataType(customDataType: KnownFieldTypes.ChipChoice)]
     [Choice("[{\"Title\":\"1 level\",\"Name\":\"1\",\"Value\":1,\"Icon\":null},{\"Title\":\"2 levels\",\"Name\":\"2\",\"Value\":2,\"Icon\":null},{\"Title\":\"3 levels\",\"Name\":\"3\",\"Value\":3,\"Icon\":null}]")]
     public int? IntAsChoice { get; set; }
       
     //Dropdown
     [DefaultValue(1)]
     [DataType(customDataType: KnownFieldTypes.Choices)]
     [Choice("[{\"Title\":\"1 level\",\"Name\":\"1\",\"Value\":1,\"Icon\":null},{\"Title\":\"2 levels\",\"Name\":\"2\",\"Value\":2,\"Icon\":null},{\"Title\":\"3 levels\",\"Name\":\"3\",\"Value\":3,\"Icon\":null}]")]
     public int? IntAsDropdownChoice { get; set; }
     
     //External data choice for single selection 
     [ExternalDataChoice] 
     [DataType(customDataType: KnownFieldTypes.Choices)] 
     public string DynamicChoiceSingle { get; set; } 

     //External data choice For multiple selection 
     [ExternalDataChoice] 
     [DataType(customDataType: KnownFieldTypes.ChoiceMultiple)] 
     public string DynamicChoiceMultiple { get; set; } 
     
     //Password field
     [DataType(customDataType: KnownFieldTypes.Password)]
     public string Password { get; set; }
     
     //Range field
     [DataType(customDataType: KnownFieldTypes.Range)]
     [Suffix("MB")]
     public NumericRange Range { get; set; }

     //File types field
     [DataType(customDataType: KnownFieldTypes.FileTypes)]
     [DisplayName("File types")]
     public FileTypes FileTypes { get; set; }

     //Attributes
     [DataType(customDataType: KnownFieldTypes.Attributes)]
     [LengthDependsOn(null, "", "", ExtraRecords = "[{\"Name\": \"wrapper\", \"Title\": \"Wrapper attributes\"}, {\"Name\": \"child\", \"Title\": \"Child attributes\"}]")]
     public IDictionary<string, IList<AttributeModel>> Attributes { get; set; }
  }
  
   public enum EnumSingle
   {
       Value1,
       Value2,
       Value3
   }

   public class AttributeModel
   {
       public string Key { get; set; }
       public string Value { get; set; }
   }

   public class NumericRange
   {
       public int? Min { get; set; }
       public int? Max { get; set; }
   }
   public class FileTypes
   {
       public string Type { get; set; }
       public string Other { get; set; }
   }
}
```# Customize autogenerated fields

## ViewSelector

If your widget has more than one views, you can use this attribute to visualize the views of the widget designer in a dropdown box, so that the user can select them. You can combine it with a `DefaultValue` attribute that holds the name of the default view.

The attribute looks in the following way:

![view-selector](/Images/sf-images/default-source/default-album/view-selector1fc840b42bbc6d27ad54ff0300e02f5f.png "view-selector")

To add this attribute, use the following code:
```C#
using System.ComponentModel;
using Progress.Sitefinity.Renderer.Entities.Content;
using Progress.Sitefinity.Renderer.Designers.Attributes;
using Telerik.Sitefinity.Web.Services.Contracts.Operations.Pages.PropertyEditor.AttributeConfigurator.Attributes;

namespace SitefinityWebApp
{
   public class DemoViewSelector
   {
     [DefaultValue("Second")]
     [ViewSelector("AllProperties")]
     public string ViewNameDefaultValue { get; set; }
   }
}
````

## Copy

This attribute controls the .NET Core editor functionality for copying widget properties in another widget. You can use the copy attribute to specify which widget properties will be copied and which will be excluded when the widget is copied.

To add this attribute to a property, use the following code:

```C#
using System.ComponentModel;
using Progress.Sitefinity.Renderer.Entities.Content;
using Progress.Sitefinity.Renderer.Designers.Attributes;

namespace SitefinityWebApp
{
   public class DemoCopy
   {
     [Copy(Exclude = true)]
     public int ExcludedFromCopyProp { get; set; }
   }
}
```
