UIX Documentation
  • Namespace
  • Class
  • Tree

Namespaces

  • None
  • uix
    • data
    • ui
      • control

Classes

  • uix\data\data
  • uix\ui
  • uix\ui\box
  • uix\ui\control
  • uix\ui\control\autocomplete
  • uix\ui\control\button
  • uix\ui\control\checkbox
  • uix\ui\control\color
  • uix\ui\control\editor
  • uix\ui\control\email
  • uix\ui\control\file
  • uix\ui\control\hidden
  • uix\ui\control\number
  • uix\ui\control\post_relation
  • uix\ui\control\radio
  • uix\ui\control\select
  • uix\ui\control\separator
  • uix\ui\control\slider
  • uix\ui\control\template
  • uix\ui\control\text
  • uix\ui\control\textarea
  • uix\ui\control\toggle
  • uix\ui\footer
  • uix\ui\grid
  • uix\ui\header
  • uix\ui\help
  • uix\ui\metabox
  • uix\ui\modal
  • uix\ui\notice
  • uix\ui\page
  • uix\ui\panel
  • uix\ui\post_type
  • uix\ui\repeat
  • uix\ui\section
  • uix\ui\uix

Interfaces

  • uix\data\load
  • uix\data\save

Functions

  • uix
  • uix_autoload_class
 1 <?php
 2 /**
 3  * UIX Controls
 4  *
 5  * @package   controls
 6  * @author    David Cramer
 7  * @license   GPL-2.0+
 8  * @link
 9  * @copyright 2016 David Cramer
10  */
11 namespace uix\ui\control;
12 
13 /**
14  * Radio group input
15  *
16  * @since 1.0.0
17  */
18 class radio extends \uix\ui\control{
19 
20     /**
21      * The type of object
22      *
23      * @since       1.0.0
24      * @access public
25      * @var         string
26      */
27     public $type = 'radio';
28 
29     /**
30      * Gets the attributes for the control.
31      *
32      * @since  1.0.0
33      * @access public
34      */
35     public function set_attributes() {
36         parent::set_attributes();
37 
38         $this->attributes['type'] = $this->type;
39         unset( $this->attributes['id'] );
40 
41     }
42 
43 
44     /**
45      * Returns the main input field for rendering
46      *
47      * @since 1.0.0
48      * @see \uix\ui\uix
49      * @access public
50      * @return string 
51      */
52     public function input(){
53         
54         $input      = '';
55         $values     = (array) $this->get_value();
56         $id         = $this->id();
57 
58         foreach ($this->struct['choices'] as $option_value => $option_label) {
59             $sel        = null;
60             $option_id  = $id . '-' . sanitize_key( $option_value );
61             if( in_array( $option_value, $values ) )
62                 $sel = ' checked="checked"';
63 
64             $input .= '<div class="uix-' . esc_attr( $this->type ) . '">';
65                 $input .= '<label for="' . $option_id . '">';
66                 $input .= '<input id="' . $option_id . '" ' . $this->build_attributes() . ' value="' . esc_attr( $option_value ) . '"' . $sel . '>';
67                 $input .= esc_html( $option_label );
68                 $input .= '</label>';
69             $input .= '</div>';
70         }
71 
72         return $input;
73     }  
74 
75 }
UIX Documentation API documentation generated by ApiGen