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