O'Reilly logo

PHP 7 Programming Cookbook by Doug Bierer

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required