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: docs/development/modules.md
+35-3Lines changed: 35 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -27,7 +27,7 @@ NOTE:Before adding a Control Panel route to your add-on, you need to already hav
27
27
If your add-on doesn't already have the required `ControlPanel/Routes` and `views` files, you can add a route to your add-on using the `make:cp-route` command in the CLI.
28
28
29
29
```
30
-
$ php system/ee/eeclip.php make:cp-route
30
+
$ php system/ee/eecli.php make:cp-route
31
31
Let's create a control panel route!
32
32
What is the route name? index
33
33
What add-on is the route being added to? [amazing_add_on]: amazing_add_on
@@ -399,12 +399,44 @@ if (isset($form)) {
399
399
}
400
400
```
401
401
402
-
You're add-on will now have a Control Panel page with a form as seen in this screenshot:
402
+
Your add-on will now have a Control Panel page with a form as seen in this screenshot:
403
403
404
404

405
405
406
+
Finally, make the form submission do something. The form is being submitted to same CP controller, so we can check whether it has been submitted by adding `ee('Request')->isPost()` check. For the sake of this demo, we'll skip the database saving part and just display success message on submission.
406
407
407
-
TIP: This is only the beginning of what you can do with forms in the Control Panel. Read more in the docs on the [`CP\Form` service](development/services/cp-form.md)() to understand what else is possible.
408
+
```
409
+
public function process($id = false)
410
+
{
411
+
if (ee('Request')->isPost()) {
412
+
ee('CP/Alert')->makeBanner('amazing_add_on')
413
+
->asSuccess()
414
+
->withTitle(lang('success'))
415
+
->addToBody('Form has been submitted!')
416
+
->now();
417
+
}
418
+
419
+
// set the breadcrumb
420
+
$this->addBreadcrumb('index', 'Home');
421
+
422
+
// call our getForm() method to get
423
+
// our array
424
+
$form = $this->getForm();
425
+
426
+
// store our form in our $variables array
427
+
// to be passed into our view
428
+
$variables = [
429
+
'form' => $form
430
+
];
431
+
432
+
$this->setBody('Index', $variables);
433
+
434
+
return $this;
435
+
}
436
+
```
437
+
438
+
439
+
TIP: This is only the beginning of what you can do with forms in the Control Panel. Read more in the docs on the [`CP\Form` service](development/services/cp-form.md) to understand what else is possible.
408
440
409
441
TIP: **{ee:u}** Learn more about the [CP\Form service on ExpressionEngine University](https://u.expressionengine.com/article/ultra-double-secret-manual-shared-form-part-four).
Copy file name to clipboardExpand all lines: docs/development/services/cp-form.md
+19-19Lines changed: 19 additions & 19 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -7,17 +7,17 @@
7
7
@license https://expressionengine.com/license Licensed under Apache License, Version 2.0
8
8
-->
9
9
10
-
# Cp/Form Service
10
+
# CP/Form Service
11
11
12
12
[TOC]
13
13
14
-
The Cp/Form Service allows for the creation of Shared Form View data using an object oriented interface.
14
+
The CP/Form Service allows for the creation of Shared Form View data using an object oriented interface.
15
15
16
16
TIP: Note this requires PHP >= 7.1
17
17
18
18
## Usage
19
19
20
-
The below shows The Cp/Form Service at its simplest; every form can contain multiple groups, which can contain multiple field sets, which can contain multiple fields.
20
+
The below shows The CP/Form Service at its simplest; every form can contain multiple groups, which can contain multiple field sets, which can contain multiple fields.
21
21
22
22
### Basic
23
23
```
@@ -53,7 +53,7 @@ $form->toArray();
53
53
```
54
54
## API Reference
55
55
56
-
**class `ExpressionEngine\Library\Cp\Form`**
56
+
**class `ExpressionEngine\Library\CP\Form`**
57
57
58
58
This object contains the complete outline for your Shared Form View array. For simple forms, all you'll have to do is call the Service using EE's loader, but for more complex Forms, you have quite a few options available.
59
59
@@ -65,7 +65,7 @@ Will output the Form object as a Tabbed format array form.
65
65
66
66
| Parameter | Type | Description |
67
67
| --------- | ---- | ----------- |
68
-
| Returns |`Cp\Form`|`$this`, the Form object to help in chaining |
68
+
| Returns |`CP\Form`|`$this`, the Form object to help in chaining |
69
69
70
70
### `isTab()`
71
71
@@ -81,7 +81,7 @@ Will output the Form object as a linear array form (the default)
81
81
82
82
| Parameter | Type | Description |
83
83
| --------- | ---- | ----------- |
84
-
| Returns |`Cp\Form`|`$this`, the Form object to help in chaining |
84
+
| Returns |`CP\Form`|`$this`, the Form object to help in chaining |
85
85
86
86
### `getGroup($group_name)`
87
87
@@ -104,15 +104,15 @@ Removes the specified group from the Form object
104
104
105
105
### `toArray()`
106
106
107
-
Returns the entire Cp\Form object into an array compatible with the Shared Form View layer. Note that all child elements are converted to an array as well.
107
+
Returns the entire CP\Form object into an array compatible with the Shared Form View layer. Note that all child elements are converted to an array as well.
108
108
109
109
| Parameter | Type | Description |
110
110
| --------- | ---- | ----------- |
111
111
| Returns |`array`| The complete Shared Form View array |
112
112
113
113
### `render()`
114
114
115
-
Returns the entire Cp\Form object as a string for use within the Control Panel.
115
+
Returns the entire CP\Form object as a string for use within the Control Panel.
116
116
117
117
| Parameter | Type | Description |
118
118
| --------- | ---- | ----------- |
@@ -124,16 +124,16 @@ Sets the Shared Form View layer to set the form input's `enctype` to multipart/f
124
124
125
125
| Parameter | Type | Description |
126
126
| --------- | ---- | ----------- |
127
-
| Returns |`Cp\Form`|`$this`, the Form object to help in chaining |
127
+
| Returns |`CP\Form`|`$this`, the Form object to help in chaining |
128
128
129
129
### `addAlert($alert_name)`
130
130
131
-
Sets the Form to render specific Cp/Alert objects
131
+
Sets the Form to render specific CP/Alert objects
132
132
133
133
| Parameter | Type | Description |
134
134
| --------- | ---- | ----------- |
135
135
|\$alert_name |`string`| The name for the Alert |
136
-
| Returns |`Cp\Form`|`$this`, the Form object to help in chaining |
136
+
| Returns |`CP\Form`|`$this`, the Form object to help in chaining |
137
137
138
138
### `removeAlert($alert_name)`
139
139
@@ -152,7 +152,7 @@ Will return the specified `Form\Button` object if it exists, or prepare and retu
152
152
| Parameter | Type | Description |
153
153
| --------- | ---- | ----------- |
154
154
|\$name |`string`| The name for the Button |
155
-
| Returns |`Cp\Form\Button`| The Button object ready for use |
155
+
| Returns |`CP\Form\Button`| The Button object ready for use |
156
156
157
157
### `removeButton($name)`
158
158
@@ -170,7 +170,7 @@ Will return the specified `Form\Fields\Hidden` object if it exists, or prepare a
170
170
| Parameter | Type | Description |
171
171
| --------- | ---- | ----------- |
172
172
|\$name |`string`| The name for the Button |
173
-
| Returns |`Cp\Form\Fields\Hidden`| The Hidden Field object |
173
+
| Returns |`CP\Form\Fields\Hidden`| The Hidden Field object |
174
174
175
175
### `removeHiddenField($name)`
176
176
@@ -190,15 +190,15 @@ Will include a custom HTML button with a link in lieu of the top right button of
190
190
|\$text |`string`| The value to display on your custom button |
191
191
|\$href |`string`| What URL to send the user to |
192
192
|\$rel |`string`| For HTML directives |
193
-
| Returns |`Cp\Form`|`$this`, the Form object to help in chaining |
193
+
| Returns |`CP\Form`|`$this`, the Form object to help in chaining |
194
194
195
195
### `withOutActionButton()`
196
196
197
197
Will remove the set action button
198
198
199
199
| Parameter | Type | Description |
200
200
| --------- | ---- | ----------- |
201
-
| Returns |`Cp\Form`|`$this`, the Form object to help in chaining |
201
+
| Returns |`CP\Form`|`$this`, the Form object to help in chaining |
202
202
203
203
### `setCpPageTitle($text)`
204
204
@@ -207,7 +207,7 @@ Sets the string to use for the Page Title within the Control Panel
207
207
| Parameter | Type | Description |
208
208
| --------- | ---- | ----------- |
209
209
|\$text |`string`| The name for the page |
210
-
| Returns |`Cp\Form`|`$this`, the Form object to help in chaining |
210
+
| Returns |`CP\Form`|`$this`, the Form object to help in chaining |
211
211
212
212
### `getCpPageTitle()`
213
213
@@ -224,7 +224,7 @@ Sets the string to use for the Alternative Page Title within the Control Panel (
224
224
| Parameter | Type | Description |
225
225
| --------- | ---- | ----------- |
226
226
|\$text |`string`| The name for the page |
227
-
| Returns |`Cp\Form`|`$this`, the Form object to help in chaining |
227
+
| Returns |`CP\Form`|`$this`, the Form object to help in chaining |
228
228
229
229
### `getCpPageTitle()`
230
230
@@ -241,7 +241,7 @@ Sets the internal Alerts ID to use specific to this Form (`alerts_name`)
241
241
| Parameter | Type | Description |
242
242
| --------- | ---- | ----------- |
243
243
|\$text |`string`| The name for the page |
244
-
| Returns |`Cp\Form`|`$this`, the Form object to help in chaining |
244
+
| Returns |`CP\Form`|`$this`, the Form object to help in chaining |
245
245
246
246
### `getAlertsName()`
247
247
@@ -258,7 +258,7 @@ The URL to process the Form (`base_url`)
258
258
| Parameter | Type | Description |
259
259
| --------- | ---- | ----------- |
260
260
|\$url |`string`| The URL the form should be processed at |
261
-
| Returns |`Cp\Form`|`$this`, the Form object to help in chaining |
261
+
| Returns |`CP\Form`|`$this`, the Form object to help in chaining |
0 commit comments