| 1 |
<?php |
| 2 |
|
| 3 |
namespace Give\FormAPI\Form; |
| 4 |
|
| 5 |
class Text extends Field |
| 6 |
{ |
| 7 |
/** |
| 8 |
* Before field. |
| 9 |
* |
| 10 |
* @since 2.7.0 |
| 11 |
* @var string |
| 12 |
*/ |
| 13 |
public $beforeField = ''; |
| 14 |
|
| 15 |
/** |
| 16 |
* after field. |
| 17 |
* |
| 18 |
* @since 2.7.0 |
| 19 |
* @var string |
| 20 |
*/ |
| 21 |
public $afterField = ''; |
| 22 |
|
| 23 |
/** |
| 24 |
* Field value type. |
| 25 |
* Note: this param value can be price and decimal. |
| 26 |
* |
| 27 |
* @since 2.7.0 |
| 28 |
* @var string |
| 29 |
*/ |
| 30 |
public $dataType = ''; |
| 31 |
|
| 32 |
/** |
| 33 |
* Field value type. |
| 34 |
* Note: this param value can be price and decimal. |
| 35 |
* |
| 36 |
* @since 2.7.0 |
| 37 |
* @var string |
| 38 |
*/ |
| 39 |
public $size = ''; |
| 40 |
|
| 41 |
/** |
| 42 |
* @inheritDoc |
| 43 |
*/ |
| 44 |
public function parse($array) |
| 45 |
{ |
| 46 |
parent::parse($array); |
| 47 |
|
| 48 |
$this->beforeField = isset($array['before_field']) ? $array['before_field'] : ''; |
| 49 |
$this->afterField = isset($array['after_field']) ? $array['after_field'] : ''; |
| 50 |
$this->dataType = isset($array['data_type']) ? $array['data_type'] : ''; |
| 51 |
|
| 52 |
$type = explode('_', $this->type, 2); |
| 53 |
$this->size = false !== strpos('_', $this->type) ? array_pop($type) : ''; |
| 54 |
} |
| 55 |
|
| 56 |
/** |
| 57 |
* @inheritDoc |
| 58 |
*/ |
| 59 |
public function toArray() |
| 60 |
{ |
| 61 |
return array_merge( |
| 62 |
parent::toArray(), |
| 63 |
[ |
| 64 |
'before_field' => $this->beforeField, |
| 65 |
'after_field' => $this->afterField, |
| 66 |
] |
| 67 |
); |
| 68 |
} |
| 69 |
} |
| 70 |
|