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 the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.