This repository has been archived by the owner on Aug 22, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from Dolphiq/development
Development
- Loading branch information
Showing
19 changed files
with
322 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
# Forms Changelog | ||
|
||
## 1.0.0 - 2017-10-16 | ||
- Initial release. | ||
|
||
### Features | ||
- Easy out of the box client and server side validation with use of rules in a model. | ||
- Assign field labels in your model to use them in multiple areas. | ||
- Easily enable/disable the form in the settings. | ||
- Easily enable/disable logging form entries into the database in the settings. | ||
- Control the recipient and subject of the contact requests e-mails in the plugin settings per form. | ||
- Twig extensions, form examples and E-mail examples. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,15 @@ | ||
# Form plugin for Craft CMS 3.x | ||
|
||
Craft CMS 3 is build on top of the Yii 2 Framework. | ||
This plugin makes it possible to use forms the way the Yii 2 Framework offers. | ||
Craft CMS 3 is build on top of the Yii 2 Framework. | ||
This plugin makes it possible to use forms the way the Yii 2 Framework offers. This includes: | ||
- Easy out of the box client and server side validation with use of rules in a model. | ||
- Assign field labels in your model to use them in multiple areas. | ||
|
||
Next to this Yii 2 Framework logic, we added: | ||
- Easily enable/disable the form in the settings. | ||
- Easily enable/disable logging form entries into the database in the settings. | ||
- Control the recipient and subject of the contact requests e-mails in the plugin settings per form. | ||
- Twig extensions, form examples and E-mail examples. | ||
|
||
**Note**: This plugin may become a paid add-on when the Craft Plugin store becomes available. | ||
|
||
|
@@ -16,7 +24,7 @@ This plugin makes it possible to use forms the way the Yii 2 Framework offers. | |
|
||
2. Install plugin in the Craft Control Panel under Settings > Plugins | ||
|
||
3. Add the directory `forms` to the root directory of your craft project (next to your config and templates directory) | ||
3. Add a new directory `forms` to the root directory of your craft project (next to your config and templates directory) or copy the forms directory from the examples folder in the plugin directory | ||
|
||
## Directory structure | ||
Below you will find an example directory structure for a contact and a vacancy form | ||
|
@@ -108,12 +116,11 @@ In this case it will be named `contact` | |
|
||
// Start active form | ||
$form = ActiveForm::begin([ | ||
'action' => \craft\helpers\UrlHelper::actionUrl('dolphiq-craft3-forms/main/index', ['handle' => $handle]), | ||
'method' => 'POST', | ||
'options' => [ | ||
'data-pjax' => true, | ||
], | ||
] | ||
'action' => \craft\helpers\UrlHelper::actionUrl('dolphiq-craft3-forms/main/index', ['handle' => $handle]), | ||
'method' => 'POST', | ||
'options' => [ | ||
'data-pjax' => true, | ||
], | ||
]); | ||
|
||
?> | ||
|
@@ -246,3 +253,8 @@ You can set the following options per form: | |
This only works when the form contains the `email` attribute so the person that fills in the form can fill in his emailadress. | ||
You can fill in the following option:_ | ||
* Mail subject _The subject of the email that will be send to the customers emailaddress._ | ||
|
||
|
||
### Contributors & Developers | ||
Lucas Weijers - [email protected] | ||
Brought to you by [Dolphiq](https://dolphiq.nl) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
<?php | ||
|
||
namespace app\forms; | ||
|
||
use Craft; | ||
use plugins\dolphiq\form\models\Form; | ||
|
||
class contactForm extends Form { | ||
|
||
public $firstname = ""; | ||
public $lastname = ""; | ||
public $phone = ""; | ||
public $email = ""; | ||
public $message = ""; | ||
|
||
public function rules() | ||
{ | ||
return [ | ||
[['firstname', 'lastname', 'email', 'message'], 'required'], | ||
['email', 'email'], | ||
['phone', 'safe'] | ||
]; | ||
} | ||
|
||
public function attributeLabels() | ||
{ | ||
return [ | ||
'firstname' => Craft::t('site', 'Firstname'), | ||
'lastname' => Craft::t('site', 'Lastname'), | ||
'phone' => Craft::t('site', 'Phone'), | ||
'email' => Craft::t('site', 'Email'), | ||
'message' => Craft::t('site', 'Message'), | ||
]; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
<?php | ||
|
||
/* @var $this \yii\web\View view component instance */ | ||
/* @var $message \yii\mail\BaseMessage instance of newly created mail message */ | ||
/* @var $model app\forms\contactForm */ | ||
|
||
?> | ||
<h2>Thank you for your message <?= $model->lastname; ?></h2> | ||
<p> | ||
We will contact you as soon as possible | ||
</p> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
<?php | ||
|
||
use yii\widgets\DetailView; | ||
|
||
/* @var $this \yii\web\View view component instance */ | ||
/* @var $message \yii\mail\BaseMessage instance of newly created mail message */ | ||
/* @var $model \app\forms\contactForm */ | ||
|
||
?> | ||
<h2>A contact request has been filled in</h2> | ||
<p> | ||
We received the following details:<br> | ||
<?= DetailView::widget([ | ||
'model' => $model, | ||
'attributes' => [ | ||
'firstname', | ||
'lastname', | ||
'email', | ||
'phone', | ||
'message:ntext' | ||
] | ||
]); ?> | ||
</p> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
<?php | ||
/** | ||
* @var $model \app\forms\contactForm | ||
*/ | ||
?> | ||
|
||
<p>Thank you <?= $model->firstname ?>, we will contact you soon</p> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
<?php | ||
|
||
/** | ||
* @var $model app\forms\contactForm | ||
* @var $handle string | ||
*/ | ||
|
||
use yii\widgets\ActiveForm; | ||
use yii\widgets\Pjax; | ||
|
||
// Start ajax handling of the form | ||
Pjax::begin(['enablePushState' => false, 'id' => 'pjax-'.$handle]); | ||
|
||
// Start active form | ||
$form = ActiveForm::begin([ | ||
'action' => \craft\helpers\UrlHelper::actionUrl('dolphiq-craft3-forms/main/index', ['handle' => $handle]), | ||
'method' => 'POST', | ||
'options' => [ | ||
'data-pjax' => true, | ||
], | ||
]); | ||
|
||
?> | ||
|
||
<?= $form->field($model, 'firstname')->textInput(); ?> | ||
<?= $form->field($model, 'lastname')->textInput(); ?> | ||
<?= $form->field($model, 'phone')->textInput(); ?> | ||
<?= $form->field($model, 'email')->textInput(); ?> | ||
|
||
<?= $form->field($model, 'message')->textarea(); ?> | ||
|
||
<div> | ||
<button type="submit"> | ||
<?= Craft::t('site', 'Send request'); ?> | ||
</button> | ||
</div> | ||
|
||
|
||
<?php | ||
|
||
// End active form | ||
ActiveForm::end(); | ||
|
||
// End ajax handling | ||
Pjax::end(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
<?php | ||
|
||
namespace app\forms; | ||
|
||
use Craft; | ||
use plugins\dolphiq\form\models\Form; | ||
|
||
class vacancyForm extends Form { | ||
|
||
public $vacancy = ""; | ||
public $firstname = ""; | ||
public $lastname = ""; | ||
public $phone = ""; | ||
public $email = ""; | ||
public $message = ""; | ||
|
||
public function rules() | ||
{ | ||
return [ | ||
[['vacancy','firstname', 'lastname', 'email', 'message'], 'required'], | ||
['email', 'email'], | ||
['phone', 'safe'] | ||
]; | ||
} | ||
|
||
public function attributeLabels() | ||
{ | ||
return [ | ||
'vacancy' => Craft::t('site', 'Vacancy'), | ||
'firstname' => Craft::t('site', 'Firstname'), | ||
'lastname' => Craft::t('site', 'Lastname'), | ||
'phone' => Craft::t('site', 'Phone'), | ||
'email' => Craft::t('site', 'Email'), | ||
'message' => Craft::t('site', 'Message'), | ||
]; | ||
} | ||
|
||
public function vacancyDropdown(){ | ||
$vacancies = [ | ||
Craft::t('site', 'Director'), | ||
Craft::t('site', 'Assistant'), | ||
Craft::t('site', 'Cleaner'), | ||
Craft::t('site', 'Intern'), | ||
]; | ||
|
||
return array_combine($vacancies,$vacancies); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
<?php | ||
|
||
/* @var $this \yii\web\View view component instance */ | ||
/* @var $message \yii\mail\BaseMessage instance of newly created mail message */ | ||
/* @var $model app\forms\vacancyForm */ | ||
|
||
?> | ||
<h2>Thank you for your message <?= $model->lastname; ?></h2> | ||
<p> | ||
We will contact you as soon as possible | ||
</p> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
<?php | ||
|
||
use yii\widgets\DetailView; | ||
|
||
/* @var $this \yii\web\View view component instance */ | ||
/* @var $message \yii\mail\BaseMessage instance of newly created mail message */ | ||
/* @var $model \app\forms\vacancyForm */ | ||
|
||
?> | ||
<h2>An apply for a vacancy has been received</h2> | ||
<p> | ||
We received the following details:<br> | ||
<?= DetailView::widget([ | ||
'model' => $model, | ||
'attributes' => [ | ||
'vacancy', | ||
'firstname', | ||
'lastname', | ||
'email', | ||
'phone', | ||
'message:ntext' | ||
] | ||
]); ?> | ||
</p> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
<?php | ||
|
||
/** | ||
* @var $model app\forms\vacancyForm | ||
* @var $handle string | ||
*/ | ||
|
||
?> | ||
|
||
<p>Thank you <?= $model->firstname; ?>! We will contact you soon.</p> | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
<?php | ||
|
||
/** | ||
* @var $model app\forms\vacancyForm | ||
* @var $handle string | ||
*/ | ||
|
||
use yii\widgets\ActiveForm; | ||
use yii\widgets\Pjax; | ||
|
||
// Start ajax handling of the form | ||
Pjax::begin(['enablePushState' => false, 'id' => 'pjax-'.$handle]); | ||
|
||
// Start active form | ||
$form = ActiveForm::begin([ | ||
'action' => \craft\helpers\UrlHelper::actionUrl('dolphiq-craft3-forms/main/index', ['handle' => $handle]), | ||
'method' => 'POST', | ||
'options' => [ | ||
'data-pjax' => true, | ||
], | ||
]); | ||
|
||
?> | ||
|
||
<?= $form->field($model, 'vacancy')->dropDownList($model->vacancyDropdown()); ?> | ||
<?= $form->field($model, 'firstname')->textInput(); ?> | ||
<?= $form->field($model, 'lastname')->textInput(); ?> | ||
<?= $form->field($model, 'phone')->textInput(); ?> | ||
<?= $form->field($model, 'email')->textInput(); ?> | ||
|
||
<?= $form->field($model, 'message')->textarea(); ?> | ||
|
||
<div> | ||
<button type="submit"> | ||
<?= Craft::t('site', 'Apply'); ?> | ||
</button> | ||
</div> | ||
|
||
|
||
<?php | ||
|
||
// End active form | ||
ActiveForm::end(); | ||
|
||
// End ajax handling | ||
Pjax::end(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.