|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/** |
|
4
|
|
|
* @since 3.0 |
|
5
|
|
|
*/ |
|
6
|
|
View Code Duplication |
class FrmFieldCheckbox extends FrmFieldType { |
|
|
|
|
|
|
7
|
|
|
|
|
8
|
|
|
/** |
|
9
|
|
|
* @var string |
|
10
|
|
|
* @since 3.0 |
|
11
|
|
|
*/ |
|
12
|
|
|
protected $type = 'checkbox'; |
|
13
|
|
|
|
|
14
|
|
|
/** |
|
15
|
|
|
* @var bool |
|
16
|
|
|
* @since 3.0 |
|
17
|
|
|
*/ |
|
18
|
|
|
protected $holds_email_values = true; |
|
19
|
|
|
|
|
20
|
|
|
/** |
|
21
|
|
|
* Does the html for this field label need to include "for"? |
|
22
|
|
|
* |
|
23
|
|
|
* @var bool |
|
24
|
|
|
* @since 3.06.01 |
|
25
|
|
|
*/ |
|
26
|
|
|
protected $has_for_label = false; |
|
27
|
|
|
|
|
28
|
|
|
protected function input_html() { |
|
29
|
|
|
return $this->multiple_input_html(); |
|
30
|
|
|
} |
|
31
|
|
|
|
|
32
|
|
|
protected function include_form_builder_file() { |
|
33
|
|
|
return $this->include_front_form_file(); |
|
34
|
|
|
} |
|
35
|
|
|
|
|
36
|
|
|
protected function new_field_settings() { |
|
37
|
|
|
return array( |
|
38
|
|
|
'options' => serialize( |
|
39
|
|
|
array( |
|
40
|
|
|
__( 'Option 1', 'formidable' ), |
|
41
|
|
|
__( 'Option 2', 'formidable' ), |
|
42
|
|
|
) |
|
43
|
|
|
), |
|
44
|
|
|
); |
|
45
|
|
|
} |
|
46
|
|
|
|
|
47
|
|
|
/** |
|
48
|
|
|
* Get the type of field being displayed. |
|
49
|
|
|
* |
|
50
|
|
|
* @since 4.02.01 |
|
51
|
|
|
* @return array |
|
52
|
|
|
*/ |
|
53
|
|
|
public function displayed_field_type( $field ) { |
|
54
|
|
|
return array( |
|
55
|
|
|
$this->type => true, |
|
56
|
|
|
); |
|
57
|
|
|
} |
|
58
|
|
|
|
|
59
|
|
|
protected function extra_field_opts() { |
|
60
|
|
|
$form_id = $this->get_field_column( 'form_id' ); |
|
61
|
|
|
|
|
62
|
|
|
return array( |
|
63
|
|
|
'align' => FrmStylesController::get_style_val( 'check_align', ( empty( $form_id ) ? 'default' : $form_id ) ), |
|
|
|
|
|
|
64
|
|
|
); |
|
65
|
|
|
} |
|
66
|
|
|
|
|
67
|
|
|
/** |
|
68
|
|
|
* @since 4.06 |
|
69
|
|
|
*/ |
|
70
|
|
|
protected function show_priority_field_choices( $args = array() ) { |
|
71
|
|
|
include( FrmAppHelper::plugin_path() . '/classes/views/frm-fields/back-end/radio-images.php' ); |
|
72
|
|
|
} |
|
73
|
|
|
|
|
74
|
|
|
protected function include_front_form_file() { |
|
75
|
|
|
return FrmAppHelper::plugin_path() . '/classes/views/frm-fields/front-end/checkbox-field.php'; |
|
76
|
|
|
} |
|
77
|
|
|
|
|
78
|
|
|
protected function show_readonly_hidden() { |
|
79
|
|
|
return true; |
|
80
|
|
|
} |
|
81
|
|
|
|
|
82
|
|
|
protected function prepare_import_value( $value, $atts ) { |
|
83
|
|
|
return $this->get_multi_opts_for_import( $value ); |
|
84
|
|
|
} |
|
85
|
|
|
} |
|
86
|
|
|
|
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.
You can also find more detailed suggestions in the “Code” section of your repository.