On this page
Caution
The documentation you are viewing is for an older version of this component.
Switch to the latest (v3) version.
View Helpers
FormUrl
The FormUrl
view helper can be used to render an <input type="url">
HTML
form input. It is meant to work with the Url element, which
provides a default input specification with an URL validator.
Basic usage
use Laminas\Form\Element;
$element = new Element\Url('my-url');
// Within your view...
echo $this->formUrl($element);
Output:
<input type="url" name="my-url" value="">
Usage of custom regular expression pattern:
use Laminas\Form\Element;
$element = new Element\Url('my-url');
$element->setAttribute('pattern', 'https?://.+');
// Within your view...
echo $this->formUrl($element);
Output:
<input type="url" name="my-url" pattern="https?://.+" value="">