Once we keep on developing in Zend Framework 2, and our application keeps on growing, the more it is necessary to stop copy-pasting and just replace all those replicating bits by a class that simply outputs what we want. In ZF2 this can be done easily through view helpers.
In this recipe we'll create our own form element, and corresponding view helper to display it.
All we have to do is set the type of the element, and that's it. We do the following alterations to the /module/Application/src/Application/Form/Element/Video.php
file, let's take a look on what the code should look like:
<?php // Set our namespace just right namespace Application\Form\Element; // We need to extend from the base element use Zend\Form\Element; // Set the class name, and make sure we extend from the // base element class Video extends Element { // The type of the element is video, 'nuff said. protected $attributes ...