Documentation > CMS Template API Library > InputForm > HasField(String)
HasField
Use to see if a field with the given name is provided by the InputForm
public System.Boolean HasField(String)
Parameters
Name | Description | Type |
---|---|---|
fieldName | System.String |
Code Example
C#
Sample:
1 2 3 4 5 6 7 8 9 10 11 12 13 | if (!context.InputForm.HasField( "title" )) // If a title is not provided { // redisplay the input form with this message context.ValidationError = "Please add a title." ; } else if (!asset.Label.Equals(context.InputForm[ "title" ])) // If value is different from current label { asset.Rename(context.InputForm[ "title" ]); // rename asset to new title value. } |