Download the PHP package luyadev/luya-module-contactform without Composer
On this page you can find all versions of the php package luyadev/luya-module-contactform. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download luyadev/luya-module-contactform
More information about luyadev/luya-module-contactform
Files in luyadev/luya-module-contactform
Package luya-module-contactform
Short Description This module provides a very fast and secure way to create customizable contact forms.
License MIT
Homepage http://luya.io
Informations about the package luya-module-contactform
Contactform Module
This module provides a very fast and secure way to create customizable contact forms.
Installation
Require the contact module via composer
add the contact form module to your config:
To defined the attribute labels you can configure the module as followed:
By default LUYA will wrap the value into the Yii::t('app', $value)
functions so you are able to translate the attributes labels. The above exmaple would look like this Yii::t('app', 'E-Mail')
.
Integrate the Module
In order to use the module inside the LUYA CMS, just pick the Module Block
and drag the block into the page. After droped the block edit the module block and picke the contactform
module. This will then maybe throw an exception that there is no view file. In order to create the view file follow the next section.
View Files
Typically view files are located in views
folder of your project root, create the view file for the corresponding model data at views/contactform/default/index.php
with the following content:
when the form validation success the variable $success
will be true, in addition a Yii2 flash mesage Yii::$app->session->setFlash('contactform_success')
with the key-name contactform_success
will be set.
In order to ensure a form is only submited once use the LUYA Core SubmitButtonWidget.
Tip: In order to style required fields with asterisks, you can use the following CSS:
Trigger after success
You can define a anonmys function which will be trigger after success, the first parameter of the function can be the model which will be assigne [[\luya\base\DynamicModel]]. Example callback:
Ordering fields in email
You can oder the fields in the mail wich will be send to the contact form recipient. This could be put before the rules in the contact form config.
For short and small forms this notation could be used as well:
For long and complex form we would recommend this notation:
Advanced configuration
attribte | example |
---|---|
mailTitle |
The mail title is also known as the mail subject |
mailText |
This is a message which can be used as intro for the mail body. Markdown parsing is enabled by default. |
sendToUserEmail |
If enabled, the mail will also be sent to the user who has submitted the form, configure the property with the mail field from the model. |
callback |
An anyonymus function find the model argument in order to trigger custom functions. |