artemsites
10/8/2018 - 5:27 PM

MODx_FormIt

https://docs.modx.com/extras/revo/formit

https://modx.com/extras/package/formit
https://modx.com/extras/package/recaptchav2

// Обработчик формочки перед <form...
[[!FormIt?
   &hooks=`recaptchav2,spam,email,redirect,FormItAutoResponder`
   &emailTpl=`email-send-tpl`
   &emailTo=`[[++email]]`
   &redirectTo=`16`
   &fiarTpl=`alerting-user`
   &emailUseFieldForSubject=`1`
   &emailSubject=`Письмо с [[++site_name]]`
   &fiarSubject=`Письмо с [[++site_name]]`
   &fiarToField=`userEmail`
   &fiarFromName=`[[++site_name]]`
   &emailFromName=`[[++site_name]]`
   &fiarFrom=`info@sonorso.ru`
   &emailFrom=`info@sonorso.ru`
   &validate=`
   		emailYourMother:blank:stripTags,
      userName:required:stripTags,
      userEmail:email:required:stripTags,
      userText:required:stripTags
      `
]]

// Формочка
<form action="[[~[[*id]]]]" method="post">
	<h4>Отправить письмо нам</h4>
	<input type="hidden" name="emailYourMother" value="" /> <!--emailYourMother пустое, скрытое поле, как ловушка для ботов если заполнится значит бот заполняет форму...-->
	<label for="userName">
    <span class="">[[!+fi.error.userName]]</span>
	</label>
	<input class="" type="text" name="userName" id="userName" value="[[!+fi.userName]]" placeholder="Имя">
	<br>
	<label for="userEmail">
    <span class="">[[!+fi.error.userEmail]]</span>
	</label>
	<input class="" type="email" name="userEmail" id="userEmail" value="[[!+fi.userEmail]]" placeholder="Электронная">
	<br>
	<input class="" type="text" name="userPhone" id="userPhone" value="[[!+fi.userPhone]]" placeholder="Телефон">
	<br>
	<label for="userText">
    <span class="">[[!+fi.error.userText]]</span>
	</label>
	<textarea class="" name="userText" id="userText" placeholder="Ваше письмо нам">[[!+fi.userText]]</textarea>
	<br>
	<div class="">
	    [[!recaptchav2_render]]
	    [[!+fi.error.recaptchav2_error]]
	</div>
	<input class="" type="submit" name="submit" value="Отправить">
</form>

// Чанк для оповещения пользователя alerting-user
<h2>[[+userName]], спасибо вам за ваше письмо!</h2>
<br />
<p>"[[+userText]]"</p>
<br />
<p>Мы ответим вам после того, как прочтем его!</p>
<br />
<strong>С уважением ваш [[++site_name]] - [[++site_url]]</strong>
<br />
<strong>Вы можете что-то добавить владельцу питомника по адресу <a href="mailto:[[++email]]" target="_top"></a>[[++email]]</strong>

// Чанк-шаблон который придет администратору на почту email-send-tpl
[[+userName]] отправил вам сообщение с сайта [[++site_url]] - [[++site_name]]<br /><br />
<strong>[[+userText]]</strong><br /><br />
Вы можете ответить [[+userName]] по почте: <a href="mailto:[[+userEmail]]">[[+userEmail]]</a><br /><br />
Или перезвонить [[+userPhone]]