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

NameDescriptionType
fieldName System.String

Code Example

C#

Sample:
 
             
            
            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.
            }
            
            

Connect with Crownpeak