luyadev/luya-module-forms
最新稳定版本:1.8.1
Composer 安装命令:
composer require luyadev/luya-module-forms
包简介
A form builder module for LUYA CMS.
关键字:
README 文档
README
LUYA CMS Forms Builder
A Drag & Drop Forms Builder based on LUYA CMS Blocks.
Available forms module block extensions:
Installation
Install the extension through composer:
composer require luyadev/luya-module-forms
Add the module to the config
'modules' => [ //... 'forms' => [ 'class' => 'luya\forms\Module', ] ]
Run the migrate command which does the database table setup:
./luya migrate
Run the import command in order to setup all the need permissions:
./luya import
Adjust Mailer Component
In order to customize the mailer component which should be taken for sending the mails, define the Forms component with the given callback.
'components' => [ //... 'forms' => [ 'class' => 'luya\forms\Forms', 'emailMessage' => function (SubmissionEmail $email, Forms $form) { // your custom mailer integration is here, ensure to return a boolean // value whether sending was successfull or not! return \Yii::$app->mailer->compose() ->setFrom(...) ->setTo($email->getRecipients()) ->setSubject($email->getSubject()) ->setTextBody($email->getBodyText()) ->setHtmlBody($email->getBodyHtml()) ->send(); } ] ]
Maybe the client would like to recieve a custom email, therefore you can extract the attribute value with $email->submission->getValueByAttribute('email_attribute_in_form').
'emailMessage' => function (SubmissionEmail $email, Forms $form) { return Yii::$app->mailer->compose() ->setTo($email->submission->getValueByAttribute('email')) // receives the value from the user entered data. .... }
Create Custom Form Field Blocks
The default blocks may not suit your needs, therefore its possible to create your own from input block:
class MyDropDownBlock extends PhpBlock { use FieldBlockTrait; public function name() { return 'Dropdown'; } public function admin() { return '<p>My Dropdown {{vars.label}}</p>'; } public function frontend() { Yii::$app->forms->autoConfigureAttribute( $this->getVarValue($this->varAttribute), $this->getVarValue($this->varRule, $this->defaultRule), $this->getVarValue($this->varIsRequired), $this->getVarValue($this->varLabel), $this->getVarValue($this->varHint) ); // Use all possible options with ActiveField or use the HtmlHelper return Yii::$app->forms->form->field(Yii::$app->forms->model, $this->getVarValue($this->varAttribute)) ->dropDownList([1 => 'Foo', 2 => 'Bar']); } }
Development
Refresh message files:
./vendor/bin/luya message msgconfig.php
统计信息
- 总下载量: 6.88k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 0
- 依赖项目数: 1
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2020-09-17
