View Helpers
In This Article
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 Zend\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 Zend\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="">
Found a mistake or want to contribute to the documentation? Edit this page on GitHub!