InputfieldHidden

InputfieldHidden renders an <input type="hidden"> element for carrying values through a form without displaying them to the user

Use it for submitted state, tokens, IDs, or computed values that should be present in form data but not edited directly.

$f = $modules->get('InputfieldHidden');
$f->name = 'referrer';
$f->value = $input->get('ref');
$form->add($f);

Expand all      API reference

Properties
PropertyTypeDescription
renderValueAsInputboolWhen true, renderValue() renders the hidden input rather than display text. Default is false.
initValuestringFallback value used when the value attribute is empty. Default is ''.
Methods

render()

Returns the hidden input markup built from the field attributes.

$f = $modules->get('InputfieldHidden');
$f->name = 'token';
$f->value = 'abc123';
echo $f->render(); // <input type="hidden" name="token" value="abc123" />

renderValue()

Returns display-mode markup. By default this uses the parent Inputfield renderValue() behavior. When renderValueAsInput is true, it renders the hidden input instead.

$f = $modules->get('InputfieldHidden');
$f->name = 'token';
$f->value = 'abc123';
$f->renderValueAsInput = true;
echo $f->renderValue(); // hidden input markup

getAttributes()

Returns the input attributes. If the value attribute is empty and initValue is non-empty, initValue is used as the rendered value.

$f = $modules->get('InputfieldHidden');
$f->name = 'mode';
$f->initValue = 'edit';
echo $f->render(); // value="edit"
Notes
  • Access this inputfield with $modules->get('InputfieldHidden').
  • collapsed and columnWidth are intentionally removed from its configuration screen because a hidden input has no visible wrapper layout.
  • For shared Inputfield behavior such as attributes, name, value, showIf, processing, and validation, see the main Inputfield API documentation.

Source file: wire/modules/Inputfield/InputfieldHidden/InputfieldHidden.module

API reference: methods, properties, hooks

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

Show class?     Show args?       Only hookable?    

Properties

NameReturnSummary 
InputfieldHidden::initValue string Initial populated value if value attribute not separately populated
DEFAULT: ''
 
InputfieldHidden::renderValueAsInput bool Render the hidden input, even when in renderValue mode
DEFAULT: false
 

Additional methods and properties

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

API reference based on ProcessWire core version 3.0.269