InputfieldURL
URL input with built-in sanitization and validation
Extends [[InputfieldText]] —
text properties (minlength, maxlength, placeholder, etc.) are inherited and
documented there.
$f = $modules->get('InputfieldURL');
$f->name = 'website';
$f->label = 'Website URL';
$form->add($f); See [[Inputfield]] for the shared Inputfield API.
| Property | Type | Default | Description |
|---|---|---|---|
noRelative | bool | false | When true, relative URLs are rejected (only absolute URLs accepted) |
addRoot | bool | false | When true, prepends the site root to relative URLs |
allowIDN | bool | false | Allow internationalized domain names (e.g. http://dømain.com) |
allowQuotes | bool | false | Allow quote characters (' and ") in URLs |
When the value attribute is set, the value is run through $sanitizer->url(). If the
result is empty or cannot be reconciled with the input, an error notice is added and
the previous value is restored. If a scheme (http:// or https://) was automatically
prepended, a message notice is added.
// Require absolute URLs only
$f->noRelative = true;
// Allow IDN URLs
$f->allowIDN = true;
// Allow quote characters (rarely needed)
$f->allowQuotes = true;When addRoot = true and the site runs from a subdirectory, a note is automatically
added to the field describing how to enter local URLs without the subdirectory prefix.
- Default
maxlengthis1024. - The
stripTagsconfig option is removed (not applicable to URL inputs). - Source file:
wire/modules/Inputfield/InputfieldU R L/Inputfield U R L.module
An Inputfield for handling input of URLs in ProcessWire forms.
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: InputfieldText, Inputfield, WireData and Wire.
Common
| Name | Return | Summary | |
|---|---|---|---|
Inputfield Inputfield Inputfield | InputfieldWrapper | Configure Inputfield | |
Inputfield Inputfield Inputfield | string | Render Inputfield |
Properties
| Name | Return | Summary | |
|---|---|---|---|
| Inputfield | int bool | Whether to prepend root path DEFAULT: false | |
| Inputfield | int bool | Whether to allow IDNs DEFAULT: false | |
| Inputfield | int bool | Whether to allow quote characters in URLs DEFAULT: false | |
| Inputfield | int bool | Whether relative URLs are disabled DEFAULT: false |
Additional methods and properties
In addition to the methods and properties above, Inputfield
API reference based on ProcessWire core version 3.0.267