Inputfield is the base class for modules that collect user input for fields.

// Create an Inputfield
$inputfield = $modules->get('InputfieldText');
$inputfield->label = 'Your Name';
$inputfield->attr('name', 'your_name');
$inputfield->attr('value', 'Roderigo');
// Add to a $form (InputfieldForm or InputfieldWrapper)
$form->add($inputfield); 

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

Attribute methods / Attribute properties / Settings / Traversal / Labels / Appearance / Behavior / Other / Output / Input / States / Module / Common / Collapsed constants / SkipLabel constants / TextFormat constants / RenderValue constants

Attribute methods

Name Return Summary  
Inputfield::addClass($class) $this Add a class or classes to this Inputfield (or a wrapping element)
Inputfield::attr($key) Inputfield, array, string, int, object or float Get or set an attribute (or multiple attributes)
Inputfield::has(string $key) bool Does this Inputfield have the requested property or attribute?
Inputfield::hasClass($class) bool Does this Inputfield have the given class name (or names)?
Inputfield::isEmpty() bool Is this Inputfield empty? (Value attribute reflects an empty state)
Inputfield::removeAttr(string $key) $this Remove an attribute
Inputfield::removeClass(string $class) $this Remove the given class (or classes) from this Inputfield
Inputfield::wrapAttr() Inputfield, string, array or null Get or set attribute for the element wrapping this Inputfield

Attribute properties

These properties are retrieved or manipulated via the attribute methods above.

Name Return Summary  
Inputfield::class string HTML 'class' attribute for the Inputfield.
Inputfield::id string HTML 'id' attribute for the Inputfield (if not yet, determined automatically).
Inputfield::name string HTML 'name' attribute for Inputfield (required).
Inputfield::value mixed HTML 'value' attribute for the Inputfield.

Settings

Name Return Summary  
Inputfield::get(string $key) mixed or null Get a property or attribute from the Inputfield
Inputfield::getSetting(string $key) mixed Gets a setting (or API variable) from the Inputfield, while ignoring attributes.
Inputfield::has(string $key) bool Does this Inputfield have the requested property or attribute?
Inputfield::set(string $key, mixed $value) Inputfield or WireData Set a property or attribute to the Inputfield

Traversal

Name Return Summary  
Inputfield::getParent() InputfieldWrapper or null Get this Inputfield’s parent InputfieldWrapper, or NULL if it doesn’t have one.
Inputfield::getParents() array Get array of all parents of this Inputfield.
Inputfield::setParent(InputfieldWrapper $parent) $this Set the parent (InputfieldWrapper) of this Inputfield.

Labels

Name Return Summary  
Inputfield::description string Optional description that appears under label to provide more detailed information.
Inputfield::icon string Optional font-awesome icon name to accompany label (excluding the "fa-") part).
Inputfield::label string Primary label text that appears above the input.
Inputfield::notes string Optional notes that appear under input area to provide additional notes.

Appearance

Name Return Summary  
Inputfield::collapsed int Whether the field is collapsed or visible, using one of the "collapsed" constants.
Inputfield::columnWidth int Width of column for this Inputfield 10-100 percent. 0 is assumed to be 100 (default).
Inputfield::showIf string Optional conditions under which the Inputfield appears in the form (selector string).
Inputfield::skipLabel int Skip display of the label? See the "skipLabel" constants for options.

Behavior

Name Return Summary  
Inputfield::required int or bool Set to true (or 1) to make input required, or false (or 0) to make not required (default=0).
Inputfield::requiredIf string Optional conditions under which input is required (selector string).
Inputfield::useLanguages bool or null When multi-language support active, can be set to true to make it provide inputs for each language, where supported (default=false).

Other

Name Return Summary  
Inputfield::appendMarkup string or null Optional markup to append to the Inputfield content container.
Inputfield::contentClass string Optional class name (CSS) to apply to the InputfieldContent element
Inputfield::hasFieldtype null or bool or Fieldtype The Fieldtype using this Inputfield, or boolean false when known not to have a Fieldtype, or null when not known.
Inputfield::headerClass string Optional class name (CSS) to apply to the InputfieldHeader element
Inputfield::prependMarkup string or null Optional markup to prepend to the Inputfield content container.
Inputfield::wrapClass string Optional class name (CSS) to apply to the HTML element wrapping the Inputfield.

Output

Name Return Summary  
Inputfield::entityEncode(string $str) string Entity encode a string with optional Markdown support.
Inputfield::entityEncodeLabel null or bool or int Set to boolean false to specifically disable entity encoding of field header/label (default=true).
Inputfield::entityEncodeText null or bool Set to boolean false to specifically disable entity encoding for other text: description, notes, etc. (default=true).
Inputfield::render() string Render the HTML input element(s) markup, ready for insertion in an HTML form.
Inputfield::renderReady() bool Method called right before Inputfield markup is rendered, so that any dependencies can be loaded as well.
Inputfield::renderValue() string Render just the value (not input) in text/markup for presentation purposes.
Inputfield::renderValueFlags int Options that can be applied to renderValue mode, see "renderValue" constants (default=0).

Input

Name Return Summary  
Inputfield::processInput(WireInputData $input) $this Process input for this Inputfield directly from the POST (or GET) variables

States

Name Return Summary  
Inputfield::editable() bool Get or set editable state for this Inputfield
Inputfield::error(string $text) mixed Record an error for this Inputfield
Inputfield::getErrors() array Return array of strings containing errors that occurred during input processing

Module

Methods primarily of interest during module development.

Name Return Summary  
Inputfield::getConfigAllowContext(Field $field) array Return a list of config property names allowed for fieldgroup/template context
Inputfield::getConfigArray() array Alternative method for configuration that allows for array definition
Inputfield::getConfigInputfields() InputfieldWrapper Get any custom configuration fields for this Inputfield
Inputfield::init() (nothing) Per the Module interface, init() is called after any configuration data has been populated to the Inputfield, but before render.
Inputfield::install() (nothing) Per the Module interface, this method is called when this Inputfield is installed
Inputfield::uninstall() (nothing) Per the Module interface, uninstall() is called when this Inputfield is uninstalled

Common

Name Return Summary  
Inputfield::renderReadyHook(bool $renderValueMode) (nothing) Hookable version of renderReady(), not called unless 'renderReadyHook' is hooked

Collapsed constants

Constants allowed for the Inputfield::collapsed property.

Name Return Summary  
Inputfield::collapsedBlank const 2 Collapsed only when blank
Inputfield::collapsedBlankAjax const 11 Collapsed only when blank, and dynamically loaded by AJAX when opened
Inputfield::collapsedHidden const 4 Hidden, not rendered in the form at all
Inputfield::collapsedNever const 9 Never collapsed, and not collapsible
Inputfield::collapsedNo const 0 Not collapsed (display as "open", default)
Inputfield::collapsedNoLocked const 7 Not collapsed, value visible but not editable
Inputfield::collapsedPopulated const 5 Collapsed only when populated
Inputfield::collapsedYes const 1 Collapsed unless opened
Inputfield::collapsedYesAjax const 10 Collapsed and dynamically loaded by AJAX when opened
Inputfield::collapsedYesLocked const 8 Collapsed unless opened (value becomes visible but not editable)

SkipLabel constants

Constants allowed for the Inputfield::skipLabel property.

Name Return Summary  
Inputfield::skipLabelBlank const 4 Skip rendering of the label when it is blank
Inputfield::skipLabelFor const true Don't use a "for" attribute with the <label>
Inputfield::skipLabelHeader const 2 Don't use a label header element at all (basically, skip the label)
Inputfield::skipLabelNo const false Don't skip the label (default)

TextFormat constants

Constants for formats allowed in description, notes, label.

Name Return Summary  
Inputfield::textFormatBasic const 4 Only allow basic/inline markdown, and no HTML (default)
Inputfield::textFormatMarkdown const 8 Full markdown support with HTML also allowed
Inputfield::textFormatNone const 2 Plain text: no type of markdown or HTML allowed

RenderValue constants

Options for Inputfield::renderValueFlags property, applicable Inputfield::renderValue() method call.

Name Return Summary  
Inputfield::renderValueFirst const 8 If there are multiple items, only render the first (where supported by the Inputfield).
Inputfield::renderValueMinimal const 2 Render only the minimum output when in "renderValue" mode.
Inputfield::renderValueNoWrap const 4 Indicates a parent InputfieldWrapper is not required when rendering value.

Additional methods and properties

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