renderFormControl()

Overview

public string function renderFormControl(
      required string  name          
    , required string  type          
    ,          string  context       
    ,          string  id            
    ,          string  label          = ""
    ,          string  savedValue     = ""
    ,          string  defaultValue   = ""
    ,          string  help           = ""
    ,          struct  savedData     
    ,          string  savedDataField = ""
    ,          string  error          = ""
    ,          boolean required       = false
    ,          string  layout         = "formcontrols.layouts.field"
)

Renders an individual form control. If in doubt, you should use renderForm instead of rendering individual form controls.

Arguments

NameTypeRequiredDescription
namestringYesThe name of the field to use
typestringYesThe control type, e.g. 'richeditor'
contextstringNoThe context
idstringNoThe HTML ID to use for the rendered form control
labelstringNo (default="")The label for the control. Can be an i18n resource URI.
savedValuestringNo (default="")
defaultValuestringNo (default="")The default value to prepopulate the control with (e.g. a saved value from the database)
helpstringNo (default="")Help text to accompany the control. Can be an i18n resource URI.
savedDatastructNoStructure of saved data for the entire form that is being rendered.
savedDataFieldstringNo (default="")If specified, the form control's defaultValue will be sourced from this alternate field in savedData
errorstringNo (default="")Error string to display with the control
requiredbooleanNo (default=false)Whether or not the form field is required
layoutstringNo (default="formcontrols.layouts.field")Viewlet to use to render the field's layout