InputfieldToggle class

A toggle providing similar input capability to a checkbox but much more configurable.

Click any linked item for full usage details and examples. Hookable methods are indicated with the icon. In addition to those shown below, the InputfieldToggle class also inherits all the methods and properties of: Inputfield, WireData and Wire.

Show class?             Show args?        

Common

NameReturnSummary 
addOption($value)
$thisAdd a selectable option (custom API usage only, overrides built-in options) 
defaultOption string Default selected value of 'no', 'yes', 'other' or 'none' (default='none') 
formatLabel(string $label)
stringFormat label for HTML output (entity encode, etc.) 
getAllLabels()
arrayGet all possible labels for all label types and all languages 
getConfigAllowContext(Field $field)
arrayReturn a list of config property names allowed for fieldgroup/template context
getConfigInputfields()
InputfieldWrapperConfigure Inputfield
getInputfield()
mixedGet the delegated Inputfield that will be used for rendering selectable options
getLabels()
arrayGet labels for the given label type 
getOptions()
arrayGet all selectable options as array of [ value => label ] 
getValueLabel()
stringGet the label for the currently set (or given) value 
inputfieldClass string Inputfield class to use or blank for this toggle buttons (default='') 
isEmpty()
boolIs the current value empty? (i.e. no selection) 
labelType int Label type to use, see the labelType constants (default=labelTypeYes) 
noLabel string Custom no/off label  
otherLabel string Custom label for optional other value Label to use for "other" option 
processInput(WireInputData $input)
$thisProcess input
render()
stringRender input element(s)
renderReady()
boolRender ready 
renderValue()
stringRender value
sanitizeValue($value)
int stringSanitize the value to be one ofthe constants: valueYes, valueNo, valueOther, valueUnknown 
setAttribute($key, $value)
InputfieldSet attribute 
setOptions(array $options)
$thisSet all options with array of [ value => label ] (custom API usage only, overrides built-in options) 
useDeselect bool int Allow radios or toggles to be de-selected, enabling possibility of no-selection? (default=false) 
useOther int bool Use the "other" option? (default=false) 
useReverse int bool Reverse the order of the Yes/No options? (default=false) 
useVertical bool int Use vertically oriented radio buttons? Applies only if $inputfieldClass is 'InputfieldRadios' (default=false) 
value int string Integer value when selection is made or blank string when no selection (0=No, 1=Yes, 2=Other, ''=Unknown) 
valueType int Type of value for methods that ask for it (use one of the valueType constants) 
wired()
(nothing) 
yesLabel string Custom yes/on label 

Additional methods and properties

In addition to the methods and properties above, InputfieldToggle also inherits the methods and properties of these classes:

API reference based on ProcessWire core version 3.0.244

“The end client and designer love the ease at which they can update the website. Training beyond how to log in wasn’t even necessary since ProcessWire’s default interface is straightforward.” —Jonathan Lahijani