-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathfields.php
115 lines (102 loc) · 2.94 KB
/
fields.php
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
108
109
110
111
112
113
114
115
<?php
$fields = array();
// Text Input
$fields[] = array(
'type' => 'text',
'name' => 'my_textfield',
'label' => 'My Text Field',
'id' => 'my_textfield', // (optional, will default to name)
'value' => 'Default Value' // (optional, will default to '')
);
// Color Input
$fields[] = array(
'type' => 'color',
'name' => 'my_colorfield',
'label' => 'My Color Field',
'id' => 'my_colorfield', // (optional, will default to name)
'value' => '#FFFFFF' // (optional, will default to '')
);
// Textarea Input
$fields[] = array(
'type' => 'textarea',
'name' => 'my_textarea',
'label' => 'My Textarea',
'id' => 'my_textarea', // (optional, will default to name)
'value' => 'Default Value' // (optional, will default to '')
);
// Checkbox Input
$fields[] = array(
'type' => 'checkbox',
'name' => 'my_checkbox',
'label' => 'My Checkbox',
'id' => 'my_checkbox', // (optional, will default to name)
'value' => 1 // (optional, 1 is checked, will default to 0)
);
// Select List
$fields[] = array(
'type' => 'select',
'name' => 'my_select',
'label' => 'My Select',
'id' => 'my_select', // (optional, will default to name)
'value' => 'red', // (optional, will default to '')
'select_options' => array(
array('value'=>'red', 'label' => 'Red'),
array('value'=>'blue', 'label' => 'Blue'),
array('value'=>'green', 'label' => 'Green')
)
);
// Radio List
$fields[] = array(
'type' => 'radio',
'name' => 'my_radio',
'label' => 'My Radio',
'id' => 'my_radio', // (optional, will default to name)
'value' => 'red', // (optional, will default to '')
'radio_options' => array(
array('value'=>'red', 'label' => 'Red'),
array('value'=>'blue', 'label' => 'Blue'),
array('value'=>'green', 'label' => 'Green')
)
);
// Upload Field
$fields[] = array(
'type' => 'upload',
'name' => 'my_upload',
'label' => 'My Upload',
'id' => 'my_upload', // (optional, will default to name)
'value' => 'Default Value' // (optional, will default to '')
);
// Wordpress Editor
$fields[] = array(
'type' => 'editor',
'name' => 'my_editor',
'label' => 'My Editor',
'id' => 'my_editor', // (optional, will default to name)
'value' => 'Default Value', // (optional, will default to '')
'editor_settings' => array('media_buttons' => false) // (optional, settings found in wp_editor arguments)
);
// Multi Field
$my_multi_fields = array();
$my_multi_fields[] = array(
'type' => 'radio',
'name' => 'my_multi_radio',
'label' => 'My Multi Radio',
'radio_options' => array(
array('value'=>'red', 'label' => 'Red'),
array('value'=>'blue', 'label' => 'Blue'),
array('value'=>'green', 'label' => 'Green')
)
);
$my_multi_fields[] = array(
'type' => 'text',
'name' => 'my_multi_text',
'label' => 'My Multi Text'
);
$fields[] = array(
'type' => 'multi',
'name' => 'my_multi',
'label' => 'My Multi',
'id' => 'my_multi', // (optional, will default to name)
'limit' => 3, // (optional, will default to unlimited)
'fields' => $my_multi_fields
);