dmstr / yii2-contact-module
Yii 2.0 框架的联系方式表单管理器
3.3.0
2024-05-29 09:30 UTC
Requires
- dmstr/yii2-json-editor: ^1.4.2
- dmstr/yii2-prototype-module: >=0.5.4
- justinrainbow/json-schema: ^5.2.0
- kartik-v/yii2-export: ^1.2
- yiisoft/yii2: ^2.0.11
- dev-master
- 3.3.0
- 3.2.0
- 3.1.0
- 3.0.3
- 3.0.2
- 3.0.1
- 3.0.0
- 2.2.0
- 2.1.0
- 2.0.0
- 2.0.0-beta1
- 1.3.0-beta1
- 1.2.0
- 1.1.0
- 1.0.0
- 1.0.0-rc5
- 1.0.0-rc4
- 1.0.0-rc3
- 1.0.0-rc2
- 1.0.0-rc1
- 0.4.1
- 0.4.0
- 0.4.0-rc2
- 0.4.0-rc1
- 0.3.0
- 0.2.1
- 0.2.0
- 0.1.7
- 0.1.6
- 0.1.5
- 0.1.4
- 0.1.3
- 0.1.2
- 0.1.1
- 0.1.0
- dev-dev/2.x
- dev-feature/fix-export-path
- dev-feature/contact-form-widget
- dev-feature/html-purifier
- dev-feature/restore-reply-to-and-validation
- dev-release/2.0.x
- dev-feature/utf8mb4
- dev-feature/postgres-support
- dev-feature/refactor-2021-04-14
- dev-feature/eu-gdpr-checkbox
- dev-release/1.0.x
- dev-feature/switch-jsoneditor-package
This package is auto-updated.
Last update: 2024-08-29 09:59:01 UTC
README
导航到 /contact/crud/contact-template 以创建新的表单模板。
升级提示
- 如果表单是用版本 <= 1.0.0 构建的,则存在这样的约定,即您模式中的属性 reply_to 用作消息中的 'Reply-To:' 报头。
- 这种“魔法”已被移除!您现在必须将 'Reply to Schema Property' 设置为 'reply_to' 以获得相同的行为!
Twig 模板(视图)
每个表单需要 2 个 Twig 模板。导航到 /prototype/twig/index 以创建它们
contact:FORM_NAME:将渲染表单的模板contact:FORM_NAME:send:将在消息发送后渲染为“感谢页面”
其中 FORM_NAME 必须替换为您的模板名称
- 表单可以在
/contact/default/?schema=FORM_NAME中查看 - “感谢页面”可以在
/contact/default/done?schema=FORM_NAME中查看
表单 Twig 布局
{{ use('dmstr/jsoneditor/JsonEditorWidget') }}
{{ use('yii/widgets/ActiveForm') }}
<div class="container">
<div class="row">
<div class="col-md-12">
{% set form = active_form_begin({
'id': 'contact-form',
'action' : '',
'options': {
}
}) %}
{{ form.errorSummary(model) | raw }}
{{ json_editor_widget_widget({
'model': model,
'attribute': 'json',
'options': {
'id': 'contact-json'
},
'clientOptions': {
'theme': 'bootstrap3',
'disable_collapse': true,
'disable_edit_json': true,
'disable_properties': true,
'no_additional_properties': true,
'show_errors': 'interaction'
},
'schema': schema,
}) }}
<button type="submit" class="btn btn-primary">{{ t('twig-widget', 'Send') }}</button>
{{ active_form_end() }}
</div>
</div>
</div>
带有 captcha 的表单 Twig 布局(需要在 contact-template 中激活 captcha)
{{ use('dmstr/jsoneditor/JsonEditorWidget') }}
{{ use('yii/widgets/ActiveForm') }}
{{ use('yii/captcha/Captcha') }}
<div class="container">
<div class="row">
<div class="col-md-12">
{% set form = active_form_begin({
'id': 'contact-form',
'action' : '',
'options': {
}
}) %}
{{ form.errorSummary(model) | raw }}
{{ json_editor_widget_widget({
'model': model,
'attribute': 'json',
'options': {
'id': 'contact-json'
},
'clientOptions': {
'theme': 'bootstrap3',
'disable_collapse': true,
'disable_edit_json': true,
'disable_properties': true,
'no_additional_properties': true,
'show_errors': 'interaction'
},
'schema': schema,
}) }}
{{ Captcha_widget({
model: model,
attribute: 'captcha',
captchaAction: '/contact/default/captcha'
}) }}
<button type="submit" class="btn btn-primary">{{ t('twig-widget', 'Send') }}</button>
{{ active_form_end() }}
</div>
</div>
</div>
- captcha 的背景和前景颜色可以在设置模块的 captcha 部分下定义。它使用特定的颜色格式,但最后 6 个字符遵循 css 十六进制颜色代码(例如 0xff0000 是红色,0x00ff00 是绿色)
“感谢页面” Twig 布局
<div class="alert alert-success">{{ t('twig-widget', 'Thank you for your message') }}</div>
联系方式表单 widgets twig 示例
{{ use('dmstr/modules/contact/widgets/ContactForm') }}
{{ contact_form_widget({schemaName: schemaName}) }}
设置模式
{
"title": " ",
"type": "object",
"format": "grid",
"properties": {
"Company": {
"type": "string",
"minLength": 3,
"title": "Firma",
"propertyOrder": 5,
"options": {
"grid_columns": 12
}
},
"Title": {
"type": "string",
"title": "Anrede",
"minLength": 1,
"propertyOrder": 10,
"enum": [
"Herr",
"Frau"
],
"options": {
"enum_titles": [
"Herr",
"Frau"
],
"grid_columns": 2
}
},
"LastName": {
"type": "string",
"minLength": 3,
"title": "Name",
"propertyOrder": 20,
"options": {
"grid_columns": 5
}
},
"SurName": {
"type": "string",
"minLength": 3,
"title": "Vorname",
"propertyOrder": 30,
"options": {
"grid_columns": 5
}
},
"Zip": {
"type": "string",
"minLength": 5,
"title": "PLZ",
"propertyOrder": 40,
"options": {
"grid_columns": 2
}
},
"Location": {
"type": "string",
"minLength": 3,
"title": "Ort",
"propertyOrder": 50,
"options": {
"grid_columns": 5
}
},
"Street": {
"type": "string",
"title": "Straße/Hausnr.",
"minLength": 5,
"propertyOrder": 60,
"options": {
"grid_columns": 5
}
},
"Phone": {
"type": "string",
"title": "Telefon",
"minLength": 6,
"propertyOrder": 60,
"options": {
"grid_columns": 5
}
},
"Fax": {
"type": "string",
"title": "Fax",
"propertyOrder": 60,
"options": {
"grid_columns": 5
}
},
"Email": {
"type": "string",
"format": "email",
"minLength": 1,
"title": "E-Mail Adresse",
"propertyOrder": 70,
"options": {
"grid_columns": 6
}
},
"Internet": {
"type": "string",
"title": "Internet",
"propertyOrder": 70,
"options": {
"grid_columns": 6
}
},
"Message": {
"type": "string",
"format": "textarea",
"title": "Nachricht (stichwortartig)",
"propertyOrder": 90,
"options": {
"grid_columns": 12
}
}
}
}
导出
要启用导出功能,请将 kartik\grid\Module 添加到您的项目模块中