-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathPrefixFieldNewType.php
More file actions
107 lines (93 loc) · 2.34 KB
/
Copy pathPrefixFieldNewType.php
File metadata and controls
107 lines (93 loc) · 2.34 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
<?php
class PrefixFieldNewType extends FrmFieldType {
/**
* @var string
*/
protected $type = 'new-type';
/**
* Set to false if a normal input field should not be displayed.
* @var bool
*/
protected $has_input = true;
/**
* Which Formidable settings should be hidden or displayed?
*/
protected function field_settings_for_type() {
$settings = parent::field_settings_for_type();
$settings['default'] = true;
return $settings;
}
/**
* Need custom options too? Add them here or remove this function.
*/
protected function extra_field_opts() {
return array(
// name => default,
'opt1' => '',
'opt2' => 5,
);
}
protected function include_form_builder_file() {
return dirname( __FILE__ ) . '/builder-field.php';
}
/**
* Get the type of field being displayed. This is required to add a settings
* section just for this field. show_extra_field_choices will not be triggered
* without it.
*
* @return array
*/
public function displayed_field_type( $field ) {
return array(
$this->type => true,
);
}
/**
* Add settings in the builder here.
*/
public function show_extra_field_choices( $args ) {
$field = $args['field'];
include( dirname( __FILE__ ) . '/builder-settings.php' );
}
protected function html5_input_type() {
return 'text';
}
/**
* @return array|null If there is an error, return an array.
*/
public function validate( $args ) {
$errors = array();
$value = $args['value'];
if ( empty( $value ) ) {
$errors[ 'field' . $args['id'] ] = FrmFieldsHelper::get_error_msg( $this->field, 'blank' );
}
return $errors;
}
/**
* If the saved value will be different from the submitted value,
* alter it here.
*/
public function get_value_to_save( $value, $atts ) {
// Make changes to $value or remove this function.
return $value;
}
/**
* Customize the way the value is displayed in emails and views.
*
* @return string
*/
protected function prepare_display_value( $value, $atts ) {
// Make changes to $value here or remove this function.
return $value;
}
/**
* @return string Whatever shows in the front end goes here.
*/
public function front_field_input( $args, $shortcode_atts ) {
ob_start();
include( dirname( __FILE__ ) . '/front-end-field.php' );
$input_html = ob_get_contents();
ob_end_clean();
return $input_html;
}
}