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
- Uikit
- Behavior
- Other
- Output
- Input
- States
- Module
- Common
- Collapsed constants
- SkipLabel constants
- TextFormat constants
- Render constants
- RenderValue constants
Attribute methods
Name | Return | Summary | |
---|---|---|---|
Inputfield::addClass() Inputfield::addClass($class) Inputfield::addClass($class, string $property = 'class') | $this | Add a class or classes to this Inputfield (or a wrapping element) Can also be used as property: Inputfield::addClass | |
Inputfield::attr() Inputfield::attr($key) Inputfield::attr($key, $value = null) | Inputfield array string int object float | Get or set an attribute (or multiple attributes) | |
Inputfield::class() Inputfield::class() Inputfield::class($class = null) | string Inputfield | Get class attribute or add a class to the class attribute. @since 3.0.110 Can also be used as property: Inputfield::class | |
Inputfield::has() Inputfield::has(string $key) Inputfield::has(string $key) | bool | Does this Inputfield have the requested property or attribute? | |
Inputfield::hasClass() Inputfield::hasClass($class) Inputfield::hasClass($class, string $property = 'class') | bool | Does this Inputfield have the given class name (or names)? | |
Inputfield::id() Inputfield::id() Inputfield::id($id = null) | string Inputfield | Get or set the id attribute. @since 3.0.110 Can also be used as property: Inputfield::id | |
Inputfield::isEmpty() Inputfield::isEmpty() Inputfield::isEmpty() | bool | Is this Inputfield empty? (Value attribute reflects an empty state) | |
Inputfield::name() Inputfield::name() Inputfield::name($name = null) | string Inputfield | Get or set the name attribute. @since 3.0.110 Can also be used as property: Inputfield::name | |
Inputfield::removeAttr() Inputfield::removeAttr(string $key) Inputfield::removeAttr(string $key) | $this | Remove an attribute | |
Inputfield::removeClass() Inputfield::removeClass($class) Inputfield::removeClass($class, string $property = 'class') | $this | Remove the given class (or classes) from this Inputfield | |
Inputfield::wrapAttr() Inputfield::wrapAttr() Inputfield::wrapAttr($key = null, $value = null) | Inputfield string array 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::value | mixed | HTML 'value' attribute for the Inputfield. |
Settings
Name | Return | Summary | |
---|---|---|---|
Inputfield::get() Inputfield::get(string $key) Inputfield::get(string $key) | mixed null | Get a property or attribute from the Inputfield | |
Inputfield::getSetting() Inputfield::getSetting(string $key) Inputfield::getSetting(string $key) | mixed | Gets a setting (or API variable) from the Inputfield, while ignoring attributes. | |
Inputfield::has() Inputfield::has(string $key) Inputfield::has(string $key) | bool | Does this Inputfield have the requested property or attribute? | |
Inputfield::set() Inputfield::set(string $key, mixed $value) Inputfield::set(string $key, mixed $value) | Inputfield WireData | Set a property or attribute to the Inputfield |
Traversal
Labels
Name | Return | Summary | |
---|---|---|---|
Inputfield::appendMarkup() Inputfield::appendMarkup() Inputfield::appendMarkup($markup = null) | string Inputfield | Get or set the 'appendMarkup' property via method. @since 3.0.110 Can also be used as property: Inputfield::appendMarkup | |
Inputfield::description() Inputfield::description() Inputfield::description($description = null) | string Inputfield | Get or set the 'description' property via method. @since 3.0.110 Can also be used as property: Inputfield::description | |
Inputfield::detail | string | Optional text details that appear under notes. @since 3.0.140 | |
Inputfield::head() Inputfield::head() Inputfield::head($head = null) | string Inputfield | Get or set the 'head' property via method. @since 3.0.110 | |
Inputfield::icon() Inputfield::icon() Inputfield::icon($icon = null) | string Inputfield | Get or set the 'icon' property via method. @since 3.0.110 Can also be used as property: Inputfield::icon | |
Inputfield::label() Inputfield::label() Inputfield::label($label = null) | string Inputfield | Get or set the 'label' property via method. @since 3.0.110 Can also be used as property: Inputfield::label | |
Inputfield::notes() Inputfield::notes() Inputfield::notes($notes = null) | string Inputfield | Get or set the 'notes' property via method. @since 3.0.110 Can also be used as property: Inputfield::notes | |
Inputfield::prependMarkup() Inputfield::prependMarkup() Inputfield::prependMarkup($markup = null) | string Inputfield | Get or set the 'prependMarkup' property via method. @since 3.0.110 Can also be used as property: Inputfield::prependMarkup | |
Inputfield::requiredLabel() Inputfield::requiredLabel() Inputfield::requiredLabel($requiredLabel = null) | string Inputfield | Get or set the 'requiredLabel' property via method. @since 3.0.110 Can also be used as property: Inputfield::requiredLabel | |
Inputfield::tabLabel | string | Label for tab if Inputfield rendered in its own tab via Inputfield::collapsedTab* setting. @since 3.0.201 |
Appearance
Name | Return | Summary | |
---|---|---|---|
Inputfield::collapsed() Inputfield::collapsed() Inputfield::collapsed($collapsed = null) | int Inputfield | Get or set collapsed property via method. @since 3.0.110 Can also be used as property: Inputfield::collapsed | |
Inputfield::columnWidth() Inputfield::columnWidth() Inputfield::columnWidth($columnWidth = null) | int Inputfield | Get or set columnWidth property via method. @since 3.0.110 Can also be used as property: Inputfield::columnWidth | |
Inputfield::showIf() Inputfield::showIf() Inputfield::showIf($showIf = null) | string Inputfield | Get or set showIf selector property via method. @since 3.0.110 Can also be used as property: Inputfield::showIf | |
Inputfield::skipLabel() Inputfield::skipLabel() Inputfield::skipLabel($skipLabel = null) | int Inputfield | Get or set the skipLabel constant property via method. @since 3.0.110 Can also be used as property: Inputfield::skipLabel |
Uikit
Settings for Inputfields recognized and used by AdminThemeUikit.
Name | Return | Summary | |
---|---|---|---|
Inputfield::themeBlank | bool | Makes <input> element display with no minimal container / no border when true. | |
Inputfield::themeBorder | string | Border style for Inputfield, one of 'none', 'card', 'hide' or 'line'. | |
Inputfield::themeColor | string | Color theme for Inputfield, one of 'primary', 'secondary', 'warning', 'danger', 'success', 'highlight', 'none'. | |
Inputfield::themeInputSize | string | Input size height/font within Inputfield, one of 's', 'm', or 'l'. | |
Inputfield::themeInputWidth | string | Input width for text-type inputs, one of 'xs', 's', 'm', 'l', or 'f' (for full-width). | |
Inputfield::themeOffset | bool string | Offset/margin for Inputfield, one of 's', 'm', or 'l'. |
Behavior
Name | Return | Summary | |
---|---|---|---|
Inputfield::required() Inputfield::required() Inputfield::required($required = null) | string Inputfield | Get or set required state. @since 3.0.110 Can also be used as property: Inputfield::required | |
Inputfield::requiredAttr | int bool null | Use HTML5 “required” attribute when used by Inputfield and $required is true? Default=null. | |
Inputfield::requiredIf() Inputfield::requiredIf() Inputfield::requiredIf($requiredIf = null) | string Inputfield | Get or set required-if selector. @since 3.0.110 Can also be used as property: Inputfield::requiredIf | |
Inputfield::useLanguages | bool 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::contentClass() Inputfield::contentClass() Inputfield::contentClass($class = null) | string Inputfield | Get content class attribute or add a class to it. @since 3.0.110 Can also be used as property: Inputfield::contentClass | |
Inputfield::hasField | null Field | The Field object associated with this Inputfield, or null when not applicable or not known. | |
Inputfield::hasFieldtype | null bool Fieldtype | The Fieldtype using this Inputfield, or boolean false when known not to have a Fieldtype, or null when not known. | |
Inputfield::hasInputfield | null Inputfield | If this Inputfield is owned/managed by another (other than parent/child relationship), it may be set here. 3.0.176+ | |
Inputfield::hasPage | null Page | The Page object associated with this Inputfield, or null when not applicable or not known. | |
Inputfield::headerClass() Inputfield::headerClass() Inputfield::headerClass($class = null) | string Inputfield | Get header class attribute or add a class to it. @since 3.0.110 Can also be used as property: Inputfield::headerClass | |
Inputfield::wrapClass() Inputfield::wrapClass() Inputfield::wrapClass($class = null) | string Inputfield | Get wrapper class attribute or add a class to it. @since 3.0.110 Can also be used as property: Inputfield::wrapClass |
Output
Name | Return | Summary | |
---|---|---|---|
Inputfield::entityEncode() Inputfield::entityEncode(string $str) Inputfield::entityEncode(string $str, $markdown = false) | string | Entity encode a string with optional Markdown support. | |
Inputfield::entityEncodeLabel | null bool int | Set to boolean false to specifically disable entity encoding of field header/label (default=true). | |
Inputfield::entityEncodeText | null bool | Set to boolean false to specifically disable entity encoding for other text: description, notes, etc. (default=true). | |
Inputfield::render() Inputfield::render() Inputfield::render() | string | Render the HTML input element(s) markup, ready for insertion in an HTML form. | |
Inputfield::renderFlags | int | Options that can be applied to render, see "render*" constants (default=0). | |
Inputfield::renderReady() Inputfield::renderReady() Inputfield::renderReady($parent = null, bool $renderValueMode = false) | bool | Method called right before Inputfield markup is rendered, so that any dependencies can be loaded as well. | |
Inputfield::renderValue() Inputfield::renderValue() 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). | |
Inputfield::textFormat | int null | Text format to use for description/notes text in Inputfield (see textFormat constants) |
Input
Name | Return | Summary | |
---|---|---|---|
Inputfield::processInput() Inputfield::processInput(WireInputData $input) Inputfield::processInput(WireInputData $input) | $this | Process input for this Inputfield directly from the POST (or GET) variables |
States
Name | Return | Summary | |
---|---|---|---|
Inputfield::clearErrors() Inputfield::clearErrors() Inputfield::clearErrors() | (nothing) | Clear errors from this Inputfield | |
Inputfield::editable() Inputfield::editable() Inputfield::editable($setEditable = null) | bool | Get or set editable state for this Inputfield | |
Inputfield::error() Inputfield::error(string $text) Inputfield::error(string $text, int $flags = 0) | $this | Record an error for this Inputfield | |
Inputfield::getErrors() Inputfield::getErrors() Inputfield::getErrors(bool $clear = false) | 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() Inputfield::getConfigAllowContext(Field $field) Inputfield::getConfigAllowContext(Field $field) | array | Return a list of config property names allowed for fieldgroup/template context | |
Inputfield::getConfigArray() Inputfield::getConfigArray() Inputfield::getConfigArray() | array | Alternative method for configuration that allows for array definition | |
Inputfield::getConfigInputfields() Inputfield::getConfigInputfields() Inputfield::getConfigInputfields() | InputfieldWrapper | Get any custom configuration fields for this Inputfield | |
Inputfield::init() Inputfield::init() 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() Inputfield::install() Inputfield::install() | (nothing) | Per the Module interface, this method is called when this Inputfield is installed | |
Inputfield::uninstall() Inputfield::uninstall() Inputfield::uninstall() | (nothing) | Per the Module interface, uninstall() is called when this Inputfield is uninstalled |
Common
Name | Return | Summary | |
---|---|---|---|
Inputfield::getClassArray() Inputfield::getClassArray() Inputfield::getClassArray(string $property = 'class', bool $assoc = false) | array | Get classes in array for given class property | |
Inputfield::renderReadyHook() Inputfield::renderReadyHook() Inputfield::renderReadyHook(Inputfield $parent = null, bool $renderValueMode = false) | (nothing) | Hookable version of renderReady(), not called unless 'renderReadyHook' is hooked | |
Inputfield::val() Inputfield::val() Inputfield::val($value = null) | mixed | Shortcut for getting or setting “value” attribute |
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::collapsedBlankLocked const | 7 | Collapsed when blank, value visible but not editable | |
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 | 6 | Not collapsed, value visible but not editable | |
Inputfield::collapsedPopulated const | 5 | Collapsed only when populated | |
Inputfield::collapsedTab const | 20 | Collapsed into a separate tab @since 3.0.201 | |
Inputfield::collapsedTabAjax const | 21 | Collapsed into a separate tab and AJAX loaded @since 3.0.201 | |
Inputfield::collapsedTabLocked const | 22 | Collapsed into a separate tab and locked (not editable) @since 3.0.201 | |
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 show a visible header (likewise, do not show the label) | |
Inputfield::skipLabelMarkup const | 8 | Do not render any markup for the header/label at all @since 3.0.139 | |
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 |
Render constants
Name | Return | Summary | |
---|---|---|---|
Inputfield::renderFirst const | 1 | Render flags: place first in render | |
Inputfield::renderLast const | 2 | Render flags: place last in render |
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:
API reference based on ProcessWire core version 3.0.236