In This Article


Zend\Form\Element\Url is meant to be paired with the FormUrl helper for HTML5 inputs with type "url". This element adds filters and a Zend\Validator\Uri validator to its input filter specification for validating HTML5 URL input values on the server.

Basic Usage

This element automatically adds a type attribute of value url.

use Zend\Form\Element;
use Zend\Form\Form;

$url = new Element\Url('webpage-url');
$url->setLabel('Webpage URL');

$form = new Form('my-form');

Using array notation:

use Zend\Form\Element;
use Zend\Form\Form;

$form = new Form('my-form');
    'type' => Element\Url::class,
    'name' => 'webpage-url',
    'options' => [
        'label' => 'Webpage URL',

Public Methods

The following methods are specific to the Url element; all other methods defined by the parent Element class are also available.

Method signature Description
getInputSpecification() : array Returns a input filter specification, which includes a Zend\Filter\StringTrim filter, and a Zend\Validator\Uri to validate the URI string.

Found a mistake or want to contribute to the documentation? Edit this page on GitHub!