PHPackages                             dolphiq/craft3-forms - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. dolphiq/craft3-forms

AbandonedArchivedCraft-plugin[Utility &amp; Helpers](/categories/utility)

dolphiq/craft3-forms
====================

Craft 3 formulieren

1.1.4(3y ago)203.7k14[4 issues](https://github.com/Dolphiq/craft3-forms/issues)[1 PRs](https://github.com/Dolphiq/craft3-forms/pulls)MITPHP

Since Oct 16Pushed 1y ago3 watchersCompare

[ Source](https://github.com/Dolphiq/craft3-forms)[ Packagist](https://packagist.org/packages/dolphiq/craft3-forms)[ RSS](/packages/dolphiq-craft3-forms/feed)WikiDiscussions master Synced 2d ago

READMEChangelog (5)Dependencies (1)Versions (8)Used By (0)

Form plugin for Craft CMS 3.x
=============================

[](#form-plugin-for-craft-cms-3x)

Currently the project is *DISCONTINUED*. However, feel free to fork it and continue its development!
----------------------------------------------------------------------------------------------------

[](#currently-the-project-is-discontinued-however-feel-free-to-fork-it-and-continue-its-development)

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.

Requirements
------------

[](#requirements)

- Craft 3.0 (beta 28)+
- PHP 7.0+

Installation
------------

[](#installation)

1. Install with Composer

    ```
    composer require dolphiq/craft3-forms

    ```
2. Install plugin in the Craft Control Panel under Settings &gt; Plugins
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
-------------------

[](#directory-structure)

Below you will find an example directory structure for a contact and a vacancy form

As you can see each form has its own directory. The minimum files are the files in the contact directory. When using every functionallity of this plugin you have as much files as you see in the vacancy directory.

```
forms/
    contact/
        contactForm.php
        contactView.php
    vacancy/
        vacancyForm.php
        vacancyView.php
        vacancyMailOwner.php
        vacancyCustomerMail.php
        vacancyThanks.php
    thanks.php
```

Creating a new form
-------------------

[](#creating-a-new-form)

Lets say that we are going to create a contact form.

1. Create a directory with the name of your form inside the `forms` directory. This name will be your form handle later on. In this case it will be named `contact`
2. Inside this directory create two files:

    - `contactForm.php` This file is a model that defines the fields and rules for the form. The name consists of the handle appended with `Form.php`.

        This file is a model as descriped on: Make sure the class extends the Form model from the plugin and uses the `app\forms` namespace, if you don't then the plugin won't work.

        ##### Example contactForm.php

        [](#example-contactformphp)

        ```
        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'),
             ];
         }
        }
        ```
    - `contactView.php` This file is a view with which you can display your form. The name consists of the handle appended with `View.php`.

        The file is a view file as descriped on: It is important to leave the action of the activeform and the id of the pjax widget id unchanged, else your form won't work.

        ##### Example contactView.php

        [](#example-contactviewphp)

        ```
