You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+7-210Lines changed: 7 additions & 210 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -15,214 +15,11 @@ _Objective:_
15
15
16
16
_The objective of ez forms is to have a really simple and fast way to integrate forms with notifications without a lot of setup. We will be continuing to build features but we are going to keep this plugin simple to setup. Meaning features like server side form validation and heavy customiztations will most likely never be added to this forms plugin. If you need something more customized you should look into making a custom controller._
17
17
18
-
## Installation
19
-
20
-
`npm install strapi-plugin-ezforms`
21
-
22
-
or
23
-
24
-
`yarn add strapi-plugin-ezforms`
25
-
26
-
## Configuration
27
-
28
-
_Use `env('YOUR_SECRET')` if you would like to store secrets in your env_
29
-
30
-
In your `/config/plugins.js`
31
-
32
-
```
33
-
ezforms:{
34
-
config:{
35
-
captchaProvider: {
36
-
name: 'your-provider',
37
-
config: {
38
-
// captcha provider configuration
39
-
}
40
-
},
41
-
notificationProviders: [
42
-
{
43
-
name: 'notificationProvider',
44
-
enabled: true,
45
-
config: {
46
-
// Notification provider configuration
47
-
}
48
-
}
49
-
]
50
-
}
51
-
}
52
-
53
-
```
54
-
55
-
56
-
### Example Configuration
57
-
58
-
```
59
-
ezforms:{
60
-
config:{
61
-
captchaProvider: {
62
-
name: 'recaptcha',
63
-
config: {
64
-
secretKey: 'Your Key',
65
-
minimumScore: 0.5
66
-
}
67
-
},
68
-
enableFormName: true // Optional
69
-
notificationProviders: [
70
-
{
71
-
name: 'email',
72
-
enabled: true,
73
-
config: {
74
-
from: 'Your Email'
75
-
}
76
-
},
77
-
{
78
-
provider: 'twilio',
79
-
enabled: true,
80
-
config: {
81
-
accountSid: '',
82
-
authToken: '',
83
-
from: '',
84
-
}
85
-
}
86
-
]
87
-
}
88
-
}
89
-
```
90
-
91
-
92
-
#### No Captcha No Notifications (Only DB) Config
93
-
94
-
```
95
-
ezforms:{
96
-
config:{
97
-
captchaProvider: {
98
-
name: 'none',
99
-
},
100
-
notificationProviders: []
101
-
}
102
-
}
103
-
```
104
-
### Strapi Admin Panel Configuration
105
-
106
-
After you install this plugin you will see 2 new collections in the admin panel.
107
-
108
-
#### Form Submissions
109
-
110
-
This will store all of your form submissions. There are 2 parts to this collection. There is the score section which
111
-
corresponds to the captcha score (if you have captcha disabled it will display -1) The second part is the actual form data in JSON form.
112
-
#### Notification Recipients
113
-
These are all of the people that need to be notified of the submission.
114
-
115
-

116
-
117
-
| key | value |
118
-
| --- | ----------- |
119
-
| Name | String |
120
-
| Email | String |
121
-
| Number | String E164 |
122
-
123
-
_Number must be in E164 format_
124
-
125
-
#### Permission Setup
126
-
127
-
Under `Settings` > `User & Permissions Plugin` > `Roles`
128
-
129
-
You can define which roles can submit to the EZ Forms endpoint. If you want anyone to be able to submit select `Public` if you only want authenicated users to submit forms select `Authenticated` Or selected a custom role.
EzForms comes with a default controller that handles the form submission. However, if you need more advanced features or form validation you can reuse the EzForms functions so you don't need to rewrite Captcha providers or Notification providers.
4
+
5
+
## Overriding
6
+
7
+
You can create a custom controlling by following the instructions in the [official Strapi Docs](Official Strapi Docs)
Captcha providers will return an object with a valid property
21
+
```js
22
+
// invalid captcha
23
+
return {
24
+
valid:false,
25
+
message:'Missing token',
26
+
code:400
27
+
}
28
+
// valid captcha
29
+
return {
30
+
score:.75,
31
+
valid:true
32
+
}
33
+
```
34
+
35
+
### Notification Providers
36
+
37
+
You can use any of the notification providers that come with EzForms or you can create your own. Each provider takes a config variable which you can view the required data [here](/notification-providers) and data which is the formData.
By default ezforms will display data as key value pairs in a pretty format 1 level deep, anything beyond 1 level will use `JSON.stringify()`
4
+
5
+
6
+
You can see our `formatData()` function [here](https://github.com/excl-networks/strapi-plugin-ezforms/blob/master/server/services/utils/formatData.js)
7
+
8
+
## Overriding
9
+
10
+
To override this function you can create an [extension in your project](https://docs.strapi.io/developer-docs/latest/development/plugins-extension.html#within-the-extensions-folder)
11
+
12
+
```js
13
+
// ./src/extensions/ezforms/strapi-server.js
14
+
15
+
module.exports= (plugin) => {
16
+
17
+
plugin.services.formatData= () => ({
18
+
formatData(data) {
19
+
return"Custom formatData"
20
+
}
21
+
22
+
})
23
+
24
+
return plugin;
25
+
};
26
+
27
+
```
28
+
29
+
The `data` object is the `formData` object from the request.
EzForms comes with first party notification providers but you can setup your own. If you think the notification provider would be useful to others please open a PR.
4
+
5
+
In your PR simply add your provider to [notification-providers](https://github.com/excl-networks/strapi-plugin-ezforms/tree/master/server/services/notification-providers) then register it with the [services](https://github.com/excl-networks/strapi-plugin-ezforms/blob/master/server/services/index.js) and finally add a section to the [docs](https://github.com/excl-networks/strapi-plugin-ezforms/blob/master/docs)
6
+
7
+
## Overriding
8
+
9
+
To override this function you can create an [extension in your project](https://docs.strapi.io/developer-docs/latest/development/plugins-extension.html#within-the-extensions-folder)
0 commit comments