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 radio element generator

A radio button element generator will share similarities with the generic HTML form element generator. As with any generic element, a set of radio buttons needs the ability to display an overall label and errors. There are two major differences, however:

  • Typically, you will want two or more radio buttons
  • Each button needs to have its own label

How to do it...

  1. First of all, create a new Application\Form\Element\Radio class that extends Application\Form\Generic:
    namespace Application\Form\Element;
    use Application\Form\Generic;
    class Radio extends Generic
    {
      // code
    }
    
  2. Next, we define class constants and properties that pertain to the special needs of a set of radio buttons.
  3. In this illustration, we will need a ...

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