| 1 |
<?php if (! defined('ABSPATH')) exit; // Exit if accessed directly |
| 2 |
class HC3_Ui_Element_Input_Text extends HC3_Ui_Abstract_Input |
| 3 |
{ |
| 4 |
protected $el = 'input'; |
| 5 |
protected $uiType = 'input/text'; |
| 6 |
protected $bold = false; |
| 7 |
|
| 8 |
public function bold( $set = TRUE ) |
| 9 |
{ |
| 10 |
$this->bold = $set; |
| 11 |
return $this; |
| 12 |
} |
| 13 |
|
| 14 |
public function render() |
| 15 |
{ |
| 16 |
$out = $this->htmlFactory->makeElement('input') |
| 17 |
->addAttr('type', 'text' ) |
| 18 |
->addAttr('name', $this->htmlName() ) |
| 19 |
->addAttr('class', 'hc-field') |
| 20 |
// ->addAttr('class', 'hc-block') |
| 21 |
->addAttr('class', 'hc-full-width') |
| 22 |
; |
| 23 |
|
| 24 |
if( strlen($this->value) ){ |
| 25 |
$out->addAttr('value', $this->value); |
| 26 |
} |
| 27 |
|
| 28 |
$attr = $this->getAttr(); |
| 29 |
foreach( $attr as $k => $v ){ |
| 30 |
$out->addAttr( $k, $v ); |
| 31 |
} |
| 32 |
|
| 33 |
$out->addAttr('id', $this->htmlId()); |
| 34 |
|
| 35 |
if( (null !== $this->label) && strlen($this->label) ){ |
| 36 |
$placeHolder = $this->label; |
| 37 |
$placeHolder = strip_tags( $placeHolder ); |
| 38 |
|
| 39 |
$out |
| 40 |
->addAttr('placeholder', $placeHolder) |
| 41 |
; |
| 42 |
} |
| 43 |
|
| 44 |
if( $this->bold ){ |
| 45 |
$out |
| 46 |
->addAttr('class', 'hc-fs5') |
| 47 |
; |
| 48 |
} |
| 49 |
|
| 50 |
if( (null !== $this->label) && strlen($this->label) && (! $this->bold) ){ |
| 51 |
$out = $this->htmlFactory->makeLabelled( $this->label, $out, $this->htmlId() ); |
| 52 |
} |
| 53 |
|
| 54 |
return $out; |
| 55 |
} |
| 56 |
} |