我的表格:
<form id="main-contact-form" name="contact-form" ata-request="onSend" data-request-success="alert('Message Sent')">
我似乎无法找到一个表格发布;我在哪里放这个文件?我编辑哪个文件以使表单数据字段发送到我的电子邮件?我已经设置了后端邮件设置:
function onSend() { // Collect input $name = post('name'); $email = post('email'); $message = post('message'); // Submit form $to = System\Models\MailSettings::get('sender_email'); $params = compact('name','email'); Mail::sendTo($to,'temp.website::mail.newrequest',$params); return true; }
请参阅文档:
Plugin Components.
原文链接:https://www.f2er.com/php/134662.html你可以创建一个组件(SomeForm.PHP)
<?PHP namespace My\Plugin\Components; use Cms\Classes\ComponentBase; class SomeForm extends ComponentBase { public function componentDetails() { return [ 'name' => 'Form','description' => 'Some form' ]; } public function onSend() { // Collect input $name = post('name'); $email = post('email'); $message = post('message'); // Submit form $to = System\Models\MailSettings::get('sender_email'); $params = compact('name','email'); Mail::sendTo($to,$params); return true; } }
然后为它创建一个视图(例如default.htm)
<form id="main-contact-form" name="contact-form" data-request="{{ __SELF__ }}::onSend" data-request-success="alert('Message Sent')"> ... </form>
[someForm] == {% component "someForm" %}