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

Latest news

  • ProcessWire Weekly #549
    In the 549th issue of ProcessWire Weekly we’re going to check out the latest core updates, highlight one older yet still very relevant third party module, and more. Read on!
    Weekly.pw / 17 November 2024
  • Custom Fields Module
    This week we look at a new ProFields module named Custom Fields. This module provides a way to rapidly build out ProcessWire fields that contain any number of subfields/properties within them.
    Blog / 30 August 2024
  • Subscribe to weekly ProcessWire news

“We were really happy to build our new portfolio website on ProcessWire! We wanted something that gave us plenty of control on the back-end, without any bloat on the front end - just a nice, easy to access API for all our content that left us free to design and build however we liked.” —Castus, web design agency in Sheffield, UK