Completed
Pull Request — master (#114)
by
unknown
02:50
created

FrmFieldSelect   A

Complexity

Total Complexity 9

Size/Duplication

Total Lines 67
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Importance

Changes 0
Metric Value
dl 0
loc 67
rs 10
c 0
b 0
f 0
wmc 9
lcom 1
cbo 3

8 Methods

Rating   Name   Duplication   Size   Complexity  
A include_form_builder_file() 0 3 1
A field_settings_for_type() 0 6 1
A new_field_settings() 0 10 1
A show_extra_field_choices() 0 3 1
A include_front_form_file() 0 3 1
A show_readonly_hidden() 0 3 1
A prepare_import_value() 0 7 2
A sanitize_value() 0 3 1
1
<?php
2
3
/**
4
 * @since 3.0
5
 */
6
class FrmFieldSelect extends FrmFieldType {
7
8
	/**
9
	 * @var string
10
	 * @since 3.0
11
	 */
12
	protected $type = 'select';
13
14
	/**
15
	 * @var bool
16
	 * @since 3.0
17
	 */
18
	protected $holds_email_values = true;
19
20
	protected function include_form_builder_file() {
21
		return $this->include_front_form_file();
22
	}
23
24
	protected function field_settings_for_type() {
25
		return array(
26
			'clear_on_focus' => true,
27
			'size' => true,
28
		);
29
	}
30
31
	protected function new_field_settings() {
32
		return array(
33
			'options' => serialize(
34
				array(
35
					'',
36
					__( 'Option 1', 'formidable' ),
37
				)
38
			),
39
		);
40
	}
41
42
	/**
43
	 * @since 4.0
44
	 * @param array $args - Includes 'field', 'display', and 'values'
45
	 */
46
	public function show_extra_field_choices( $args ) {
47
		$this->auto_width_setting( $args );
48
	}
49
50
	protected function include_front_form_file() {
51
		return FrmAppHelper::plugin_path() . '/classes/views/frm-fields/front-end/dropdown-field.php';
52
	}
53
54
	protected function show_readonly_hidden() {
55
		return true;
56
	}
57
58
	protected function prepare_import_value( $value, $atts ) {
59
		if ( FrmField::is_option_true( $this->field, 'multiple' ) ) {
60
			$value = $this->get_multi_opts_for_import( $value );
61
		}
62
63
		return $value;
64
	}
65
66
	/**
67
	 * @since 4.0
68
	 */
69
	public function sanitize_value( &$value ) {
70
		FrmAppHelper::sanitize_value( 'sanitize_text_field', $value );
71
	}
72
}
73