Skip to content

Commit b7161b3

Browse files
committed
Add example of contact form, update fieldtype
1 parent 37374d8 commit b7161b3

File tree

3 files changed

+99
-25
lines changed

3 files changed

+99
-25
lines changed

docs/advanced/addons/fieldtypes.md

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,14 +44,14 @@ class SuperCheckbox extends Fieldtype
4444

4545
Typically a fieldtype doesn't need to define parameters up front as they are evaluated dynamically and checked for values at runtime. If you would like to support GraphQL with your fieldtype it is important to list out your parameters so the schema can be generated properly.
4646

47-
Coilpack provides a method `parameters()` for defining which parameters your fieldtype supports. This method will also pass along the ChannelField using the fieldtype so you can generate parameters for that specific field. However, this is only necessary for more complicated fieldtypes like Grid.
47+
Coilpack provides a method `parameters()` for defining which parameters your fieldtype supports. This method will also pass along the field using the fieldtype so you can generate parameters specifically for it. However, this should only be necessary for more complicated fieldtypes like Grid.
4848

4949
```php
50-
use Expressionengine\Coilpack\Models\Channel\ChannelField;
50+
use Expressionengine\Coilpack\Contracts\Field;
5151

5252
...
5353

54-
public function parameters(ChannelField $field = null): array
54+
public function parameters(Field $field = null): array
5555
{
5656
return [
5757
new Expressionengine\Coilpack\Support\Parameter([
@@ -110,3 +110,6 @@ if (ee()->has('coilpack')) {
110110
ee()->coilpack->registerFieldtype('super_checkbox', 'Addon\Fieldtypes\SuperCheckbox');
111111
}
112112
```
113+
114+
115+
use Expressionengine\Coilpack\Contracts\ListsGraphType;

docs/getting-started.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,8 @@ To use Coilpack You will need a development environment with PHP >= 7.4.0 and Co
4040
composer create-project --prefer-dist laravel/laravel:^8.0 project-name
4141
```
4242

43-
:::info
44-
Be sure to setup your webserver to point to the `public` folder inside your Laravel project. Laravel Valet and Laravel Sail will do this automatically.
43+
:::caution
44+
You must set your webserver's document root to point to the `public` folder inside your Laravel project. Laravel Valet and Laravel Sail will do this automatically.
4545
:::
4646

4747
**Configure your Laravel Project**

docs/templates/tags/email-contact.mdx

Lines changed: 91 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,106 @@
1-
# Email Contact Form
2-
3-
4-
## Example
1+
import Tabs from '@theme/Tabs';
2+
import TabItem from '@theme/TabItem';
53

6-
```php
7-
exp.email.contact_form
8-
```
4+
# Email Contact Form
95

10-
## Parameters
6+
The purpose of this tag is to create a contact form on one of your pages that your users can use to send you email.
117

12-
### Return
8+
For full documentation of available parameters please see the [ExpressionEngine Documentation](https://docs.expressionengine.com/latest/add-ons/email.html#email-contact-form).
139

14-
This parameter lets you specify a path (or full URL) where the user should be directed after the form is submitted. Upon submission, the user is presented with a standard “thank you” message and a link. If this parameter is not used, then the link will point to the page they were on prior to arriving at the email form.
10+
<Tabs>
11+
<TabItem value="native" label="Native">
1512

1613
```php
17-
exp.email.contact_form({return: 'email/thanks'})
14+
{exp:email:contact_form user_recipients="no" recipients="admin@example.com" charset="utf-8"}
15+
<h2>Support Form</h2>
16+
<p>
17+
<label for="from">Your Email:</label><br />
18+
<input type="text" id="from" name="from" size="40" maxlength="35" value="{member_email}" />
19+
</p>
20+
<p>
21+
<label for="subject">Subject:</label><br />
22+
<input type="text" id="subject" name="subject" size="40" value="Contact Form" />
23+
</p>
24+
<p>
25+
<label for="message">Message:</label><br />
26+
<textarea id="message" name="message" rows="18" cols="40">
27+
Support Email from: {member_name}
28+
Sent at: {current_time format="%Y %m %d"}
29+
</textarea>
30+
</p>
31+
<p>
32+
<input name="submit" type='submit' value='Submit Form' />
33+
</p>
34+
{/exp:email:contact_form}
1835
```
1936

20-
### Form Class
37+
</TabItem>
38+
<TabItem value="twig" label="Twig">
2139

22-
With this parameter, you can specify the css class you want the form to have, enabling fine-grained styling of the form.
40+
```twig
41+
{% set form = exp.email.contact_form({
42+
user_recipients: 'no',
43+
recipients: 'admin@example.com',
44+
charset: 'utf-8'
45+
}) %}
2346
24-
```php
25-
exp.email.contact_form({form_class: 'contact-form'})
47+
{{ form.open() | raw }}
48+
<h2>Support Form</h2>
49+
<p>
50+
<label for="from">Your Email:</label><br/>
51+
<input type="text" id="from" name="from" size="40" maxlength="35" value="{{ form.member_email }}"/>
52+
</p>
53+
<p>
54+
<label for="subject">Subject:</label><br/>
55+
<input type="text" id="subject" name="subject" size="40" value="Contact Form"/>
56+
</p>
57+
<p>
58+
<label for="message">Message:</label><br/>
59+
<textarea id="message" name="message" rows="18" cols="40">
60+
Support Email from: {{ form.member_name }}
61+
Sent at: {{ form.current_time.format("Y-m-d") }}
62+
</textarea>
63+
</p>
64+
<p>
65+
<input name="submit" type='submit' value='Submit Form'/>
66+
</p>
67+
{{ form.close() | raw }}
2668
```
2769

28-
### Form ID
70+
</TabItem>
71+
<TabItem value="blade" label="Blade">
2972

30-
With this parameter, you can specify the css id you want the form to have. The default value is ‘contact_form’.
73+
```php
74+
@php
75+
$form = $exp->email->contact_form({
76+
user_recipients: 'no',
77+
recipients: 'admin@example.com',
78+
charset: 'utf-8'
79+
})
80+
@endphp
3181

82+
{!! $form->open() !!}
83+
<h2>Support Form</h2>
84+
<p>
85+
<label for="from">Your Email:</label><br/>
86+
<input type="text" id="from" name="from" size="40" maxlength="35" value="{{ $form->member_email }}"/>
87+
</p>
88+
<p>
89+
<label for="subject">Subject:</label><br/>
90+
<input type="text" id="subject" name="subject" size="40" value="Contact Form"/>
91+
</p>
92+
<p>
93+
<label for="message">Message:</label><br/>
94+
<textarea id="message" name="message" rows="18" cols="40">
95+
Support Email from: {{ $form->member_name }}
96+
Sent at: {{ $form->current_time->format("Y-m-d") }}
97+
</textarea>
98+
</p>
99+
<p>
100+
<input name="submit" type='submit' value='Submit Form'/>
101+
</p>
102+
{!! $form->close() !!}
103+
```
32104

33-
```php
34-
exp.email.contact_form({form_id: 'contact_form'})
35-
```
105+
</TabItem>
106+
</Tabs>

0 commit comments

Comments
 (0)