| 1 |
<?php |
| 2 |
|
| 3 |
|
| 4 |
namespace JFB_Modules\Form_Record\Admin\View_Columns; |
| 5 |
|
| 6 |
use Jet_Form_Builder\Admin\Table_Views\Column_Advanced_Base; |
| 7 |
|
| 8 |
// If this file is called directly, abort. |
| 9 |
if ( ! defined( 'WPINC' ) ) { |
| 10 |
die; |
| 11 |
} |
| 12 |
|
| 13 |
class Field_Value_Column extends Column_Advanced_Base { |
| 14 |
|
| 15 |
protected $column = 'field_value'; |
| 16 |
protected $type = self::PRE; |
| 17 |
|
| 18 |
public function get_label(): string { |
| 19 |
return __( 'Value', 'jet-form-builder' ); |
| 20 |
} |
| 21 |
|
| 22 |
public function get_control( array $record = array() ): string { |
| 23 |
$type = $record['field_type'] ?? ''; |
| 24 |
$control = 'input'; |
| 25 |
|
| 26 |
switch ( $type ) { |
| 27 |
case 'repeater-field': |
| 28 |
case 'wysiwyg-field': |
| 29 |
case 'textarea-field': |
| 30 |
$control = 'textarea'; |
| 31 |
break; |
| 32 |
} |
| 33 |
|
| 34 |
return apply_filters( |
| 35 |
'jet-form-builder/table-form-fields/column-value/control', |
| 36 |
$control, |
| 37 |
$record |
| 38 |
); |
| 39 |
} |
| 40 |
|
| 41 |
public function get_control_options( array $record = array() ): array { |
| 42 |
$field_type = $record['field_type'] ?? ''; |
| 43 |
$type = 'text'; |
| 44 |
|
| 45 |
switch ( $field_type ) { |
| 46 |
case 'number-field': |
| 47 |
case 'calculated-field': |
| 48 |
case 'range-field': |
| 49 |
$type = 'number'; |
| 50 |
break; |
| 51 |
case 'color-picker-field': |
| 52 |
$type = 'color'; |
| 53 |
break; |
| 54 |
case 'date-field': |
| 55 |
$type = 'date'; |
| 56 |
break; |
| 57 |
case 'datetime-field': |
| 58 |
$type = 'datetime-local'; |
| 59 |
break; |
| 60 |
case 'time-field': |
| 61 |
$type = 'time'; |
| 62 |
break; |
| 63 |
} |
| 64 |
|
| 65 |
$options = array( |
| 66 |
'type' => $type, |
| 67 |
); |
| 68 |
|
| 69 |
return apply_filters( |
| 70 |
'jet-form-builder/table-form-fields/column-value/control-options', |
| 71 |
$options, |
| 72 |
$record |
| 73 |
); |
| 74 |
} |
| 75 |
} |
| 76 |
|