【发布时间】:2019-07-01 11:41:16
【问题描述】:
我的问题:
我在 Azure 上运行 OctoberCMS,并尝试在 10 月使用“Magic Forms”插件。我正在使用通用表单并成功提交并显示在后端。
我的问题是我想在提交表单时发送电子邮件通知,我设置了 stmp 并且测试消息正确发送,但提交时没有任何反应。
我的另一个问题是验证或 JsOnSuccess 都没有触发。
我尝试过的一些事情:
我已经为名称字段设置了我自己的规则和我自己的规则消息,但没有任何改变。
我已尝试对所有电子邮件详细信息进行硬编码,但仍然没有发送电子邮件,即使测试消息有效。
我的表单代码:
[viewBag]
snippetCode = "formAccountingServices"
snippetName = "Form Accounting Services"
[emptyForm formAccountingServices]
group = "Accounting-Services"
rules[name] = "required"
rules[email] = "required|email"
rules[phone] = "required"
rules[service] = "required"
rules[message] = "required"
messages_success = "Your form was successfully submitted"
messages_errors = "There were errors with your submission"
mail_enabled = 1
mail_subject = "Test Subject"
mail_recipients[] = "myemail@gmail.ie"
mail_replyto = "emailFromForm@gmail.com"
reset_form = 1
redirect = "https://myHomeUrl.com"
inline_errors = "display"
js_on_success = "window.location.href = 'http://stackoverflow.com;'"
sanitize_data = "disabled"
anonymize_ip = "disabled"
recaptcha_theme = "light"
recaptcha_type = "image"
recaptcha_size = "normal"
==
<form data-request="{{ formAccountingServices}}::onFormSubmit">
{{ form_token() }}
<div id="{{ formAccountingServices }}_forms_flash"></div>
<div class="form-group">
<label for="name">Name:</label>
<input type="text" id="name" name="name" class="form-control">
</div>
<div class="form-group">
<label for="email">Email:</label>
<input type="text" id="email" name="email" class="form-control">
</div>
<div class="form-group">
<label for="phone">Phone:</label>
<input type="text" id="phone" name="phone" class="form-control">
</div>
<div class="form-group">
<label for="service">Service of interest</label>
<select name="service" id="service" class="form-control">
<option value="Accounting Services">Accounting Services</option>
<option value="Legal Services">Legal Services</option>
</select>
</div>
<div class="form-group">
<label for="message">Message</label>
<textarea id="message" name="message" rows="8" cols="80"></textarea>
</div>
<button id="simpleContactSubmitButton" type="submit" class="btn btn-default">Submit</button>
</form>
预期结果:
- 我希望所有字段都是必需的,如果某些字段为空则不允许提交。
- 成功提交表单后,它将向设置的电子邮件地址发送一封通知电子邮件并重定向到主页。
- 提交失败时显示错误消息。
实际结果:
- 无论字段是否为空,每次都会提交表单。
- 不发送通知电子邮件。
- 页面未重定向。
【问题讨论】:
-
您能否向我们展示您用于验证的代码以及用于通知的代码,如果您向我们展示该代码,我们可以提供帮助
-
我正在使用 Magic Forms 插件,因此我不必自己编写验证和通知电子邮件,因为我正在努力节省开发时间。我设法通过将代码从模式移动到页面来解决这个问题,并且它刚刚工作。
标签: laravel octobercms octobercms-plugins