Creating an HTML select element generator

Generating an HTML single select element is similar to the process of generating radio buttons. The tags are structured differently, however, in that both a SELECT tag and a series of OPTION tags need to be generated.

How to do it...

  1. First of all, create a new Application\Form\Element\Select class that extends Application\Form\Generic.
  2. The reason why we extend Generic rather than Radio is because the structuring of the element is entirely different:
    namespace Application\Form\Element;
    
    use Application\Form\Generic;
    
    class Select extends Generic
    {
      // code
    }
  3. The class constants and properties will only need to add slightly to Application\Form\Generic. Unlike radio buttons or checkboxes, there is no need to account ...

Get PHP 7 Programming Cookbook now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.