-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathform_example.php
56 lines (51 loc) · 1.49 KB
/
form_example.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
<?php
$fields = [
'user_meta' => [
[
'field' => 'full_name',
'label' => __('Full Name', ''),
'rules' => 'required|min_word[2]'
],
[
'field' => 'user_email',
'label' => __('Email', ''),
'rules' => 'required|is_email|email_exists'
],
[
'field' => 'billing_phone',
'label' => __('Phone Number', ''),
'rules' => 'required|regex_match[/^[0-9]{1} [0-9]{3} [0-9]{3} [0-9]{2} [0-9]{2}$/]'
],
[
'field' => 'user_url',
'label' => __('Website', ''),
'rules' => 'required|is_url'
],
[
'field' => 'linkedin',
'label' => __('Linkedin', ''),
'rules' => 'is_url'
],
]
];
$validation = form_validation($fields);
## if validation is successful
if($validation['status']){
// do something.
// maybe you can save data to database (:
}else {
// if validation is fail
print_r($validation['errors']);
}
?>
<!-- Example Form -->
<form action="" method="post" accept-charset="utf-8" class="form" id="" role="form">
<div class="row">
<div class="col-md-6 col-xs-12">
<div class="form-group form-item">
<label for="full_name"><?php _e('Full Name', ''); ?></label>
<input type="text" class="form-control" id="full_name" name="user_meta[full_name]" placeholder="" required/>
</div>
</div>
</div>
</form>