Inputfield class
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);
There are 42 Inputfield types in the core, plus many more Inputfield modules in our directory.
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
- Languages
- Advanced
- Collapsed constants
- SkipLabel constants
- TextFormat constants
- Render constants
- RenderValue constants
Attribute methods
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. 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. 3.0.110 Can also be used as property: Inputfield::description | |
Inputfield::detail | string | Optional text details that appear under notes. 3.0.140 | |
Inputfield::head() Inputfield::head() Inputfield::head($head = null) | string Inputfield | Get or set the 'head' property via method. 3.0.110 | |
Inputfield::icon() Inputfield::icon() Inputfield::icon($icon = null) | string Inputfield | Get or set the 'icon' property via method. 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. 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. 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. 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. 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. 3.0.201 |
Appearance
Name | Return | Summary | |
---|---|---|---|
Inputfield::collapsed() Inputfield::collapsed() Inputfield::collapsed($collapsed = null) | int Inputfield | Get or set collapsed property via method. 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. 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. 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. 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. 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. 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 . |
Other
Name | Return | Summary | |
---|---|---|---|
Inputfield::contentClass() Inputfield::contentClass() Inputfield::contentClass($class = null) | string Inputfield | Get content class attribute or add a class to it. 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. 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. 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 . | |
Inputfield::entityEncodeText | null bool | Set to boolean false to specifically disable entity encoding for other text: description, notes, etc. . | |
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 . 3.0.204 | |
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 . | |
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() | None | 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() | None | 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() | None | Per the Module interface, this method is called when this Inputfield is installed | |
Inputfield::uninstall() Inputfield::uninstall() Inputfield::uninstall() | None | Per the Module interface, uninstall() is called when this Inputfield is uninstalled |
Common
Languages
Name | Return | Summary | |
---|---|---|---|
Inputfield::getLanguageValue() Inputfield::getLanguageValue($language) Inputfield::getLanguageValue($language) | string mixed | Get language value for Inputfield that supports it. Requires LanguageSupport module. $language can be Language, id (int) or name (string). 3.0.238 | |
Inputfield::setLanguageValue() Inputfield::setLanguageValue($language, $value) Inputfield::setLanguageValue($language, $value) | None | Set language value for Inputfield that supports it. Requires LanguageSupport module. $language can be Language, id (int) or name (string). 3.0.238 | |
Inputfield::useLanguages | bool null | When multi-language support active, can be set to true to make it provide inputs for each language, where supported . |
Advanced
Name | Return | Summary | |
---|---|---|---|
Inputfield::footerMarkup | string null | Optional markup to add to the '.Inputfield' container, after '.InputfieldContent'. 3.0.241 |
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 @3.0.201 | |
Inputfield::collapsedTabAjax const | 21 | Collapsed into a separate tab and AJAX loaded @3.0.201 | |
Inputfield::collapsedTabLocked const | 22 | Collapsed into a separate tab and locked (not editable) @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 @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:
Core Inputfield types
Type | Summary |
---|---|
InputfieldAsmSelect | Multiple selection, progressive enhancement to select multiple |
InputfieldButton | Form button element that you can optionally pass an href attribute to. |
InputfieldCKEditor | CKEditor textarea rich text editor. |
InputfieldCheckbox | Single checkbox toggle |
InputfieldCheckboxes | Multiple checkbox toggles |
InputfieldCommentsAdmin | Provides an administrative interface for working with comments |
InputfieldDatetime | Inputfield that accepts date and optionally time |
InputfieldEmail | E-Mail address in valid format |
InputfieldFieldset | Groups one or more fields together in a container |
InputfieldFile | One or more file uploads (sortable) |
InputfieldFloat | Floating point number with precision |
InputfieldForm | Contains one or more fields in a form |
InputfieldHidden | Hidden value in a form |
InputfieldIcon | Select an icon |
InputfieldImage | One or more image uploads (sortable) |
InputfieldInteger | Integer (positive or negative) |
InputfieldMarkup | Contains any other markup and optionally child Inputfields |
InputfieldPage | Select one or more pages |
InputfieldPageAutocomplete | Multiple Page selection using auto completion and sorting capability. Intended for use as an input field for Page reference fields. |
InputfieldPageListSelect | Selection of a single page from a ProcessWire page tree list |
InputfieldPageListSelectMultiple | Selection of multiple pages from a ProcessWire page tree list |
InputfieldPassword | Password input with confirmation field that doesn't ever echo the input back. |
InputfieldRadios | Radio buttons for selection of a single item |
InputfieldRepeater | Repeats fields from another template. Provides the input for FieldtypeRepeater. |
InputfieldSelect | Selection of a single value from a select pulldown |
InputfieldSelectMultiple | Select multiple items from a list |
InputfieldSelector | Build a page finding selector visually. |
InputfieldSubmit | Form submit button |
InputfieldText | Single line of text |
InputfieldTextTags | Enables input of user entered tags or selection of predefined tags. |
InputfieldTextarea | Multiple lines of text |
InputfieldTinyMCE | TinyMCE rich text editor version 6.8.2. |
InputfieldToggle | A toggle providing similar input capability to a checkbox but much more configurable. |
InputfieldURL | URL in valid format |
API reference based on ProcessWire core version 3.0.251