PluginProbe
ShiftController Employee Shift Scheduling / 4.9.95
ShiftController Employee Shift Scheduling v4.9.95
4.9.97 4.9.96 4.9.95 4.9.74 4.9.75 4.9.76 4.9.77 4.9.78 4.9.84 4.9.85 4.9.87 4.9.91 4.9.92 trunk 2.1.0 2.1.1 2.1.2 2.2.0 2.2.1 2.2.2 2.2.3 2.2.4 2.2.5 2.2.6 3.2.4 All 38 releases
shiftcontroller / hc3 / ui / element / input / radio.php

radio.php in ShiftController Employee Shift Scheduling 4.9.95, at hc3/ui/element/input/radio.php

66 lines 1.6 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php if (! defined('ABSPATH')) exit; // Exit if accessed directly
2 class HC3_Ui_Element_Input_Radio extends HC3_Ui_Abstract_Input
3 {
4 protected $el = 'input';
5 protected $uiType = 'input/radio';
6 protected $checked = false;
7 protected $asList = false;
8
9 public function __construct( $htmlFactory, $name, $label = NULL, $value = NULL, $checked = FALSE )
10 {
11 parent::__construct( $htmlFactory, $name, $label, $value );
12 $this->checked = $checked;
13 }
14
15 public function asList( $set = TRUE )
16 {
17 $this->asList = $set;
18 return $this;
19 }
20
21 public function render()
22 {
23 $out = $this->htmlFactory->makeElement('input')
24 ->addAttr('type', 'radio' )
25 ->addAttr('name', $this->htmlName() )
26 // ->addAttr('class', 'hc-field')
27 ;
28
29 if( strlen($this->value) ){
30 $out->addAttr('value', $this->value);
31 }
32
33 if( $this->checked ){
34 $out->addAttr('checked', 'checked');
35 }
36
37 $out->addAttr('id', $this->htmlId());
38
39 $attr = $this->getAttr();
40 foreach( $attr as $k => $v ){
41 $out->addAttr($k, $v);
42 }
43
44 if( strlen($this->label) ){
45 $label = $this->htmlFactory->makeElement('label', $this->label)
46 ->addAttr('for', $this->htmlId())
47 // ->addAttr('class', 'hc-fs2')
48 ;
49
50 if( $this->asList ){
51 $out = $this->htmlFactory->makeList( array($out, $label) )->gutter(0);
52 $out = $this->htmlFactory->makeBlock( $out )
53 ->addAttr('class', 'hc-align-center')
54 ;
55 }
56 else {
57 $out = $this->htmlFactory->makeListInline( array($out, $label) )->gutter(1);
58 $out = $this->htmlFactory->makeBlock( $out )
59 ->addAttr('class', 'hc-nowrap')
60 ;
61 }
62 }
63
64 return $out;
65 }
66 }