Created
May 25, 2023 08:00
-
-
Save sashabeep/133cc185f36c4e2ffb9f467b263c065c to your computer and use it in GitHub Desktop.
Formlister + ajax modal bootstrap
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
if(isset($_GET['page'])){ | |
$page = intval($_GET['page']); | |
if($page > 0){ | |
$doc = $modx->getDocument($page); | |
if(!empty( $doc )){ | |
$link = $modx->makeUrl($page, '', '', 'full'); | |
$title = $doc['pagetitle']; | |
$FormLister->setField('title',$title); | |
$FormLister->setField('link',$link); | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
if(!isset($_SERVER['HTTP_X_REQUESTED_WITH']) || (strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) != 'xmlhttprequest')){ | |
$modx->sendForward($modx->getConfig('error_page')); | |
die(); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[!formFake!][!FormLister? | |
&formTpl=`@CODE: | |
<h3>[*pagetitle*]</h3> | |
<p>[*introtext*]</p> | |
<form action="[~[*id*]~]" method="post" id="ajaxform" class="ajaxmodal-form"> | |
<div>[+form.messages+]</div> | |
<label class="d-block form-group"> | |
Ваше имя* : | |
<input type="text" class="form-control [+name.errorClass+]" id="name" name="name" placeholder="Как к вам обращаться" value="[+name.value+]" required> | |
[+name.error+] | |
</label> | |
<label class="d-block form-group"> | |
Файл* : | |
<input type="file" class="form-control [+file.errorClass+]" id="file" name="file" required> | |
[+file.error+] | |
</label> | |
<button type="submit" class="btn btn-primary" name="submit">Отправить</button> | |
<input type="hidden" name="title" value="[+title.value+]"> | |
<input type="hidden" name="link" value="[+link.value+]"> | |
<input type="hidden" name="formid" value="ajaxform"> | |
</form>` | |
&subject=`Заявка с сайта: [*pagetitle*]` | |
&protectSubmit=`0` | |
&submitLimit=`0` | |
&formid=`ajaxform` | |
&to=`[email protected]` | |
&attachments=`file` | |
&fileRules=`{"file":{ | |
"optional":"Не удалось загрузить файл", | |
"maxSize" : { | |
"params": 10024, | |
"message": "Размер файла не должен превышать 10 мб" | |
}}` | |
&rules=`{"name":{"required":"Введите имя"},"!file":{"required":"Мы заявки без файлов не принимаем"},"link":{"required":"Ссылка не может быть пустой"},"title":{"required":"Заголовок не может быть пустым"}}` | |
&reportTpl=`@CODE: | |
<p>На сайте «[(site_name)]» — [(site_url)] была отправлена заявка: <b>[*pagetitle*]</b></p> | |
<p><b>Отправлено со страницы:</b> [+title+] ([+link+])</p> | |
<p><b>Имя:</b> [+name+]</p> | |
<p><b>Файл:</b> [+file+]</p>[+attachments+]` | |
&successTpl=`@CODE: <h3>Отправка заявки</h3><p>Ваша заявка была успешно отправлена</p>` | |
&errorClass=`is-invalid` | |
&requiredClass=`is-invalid` | |
&messagesTpl=`@CODE: <div class="invalid-feedback">[+messages+]</div>` | |
&prepare=`formDetails` | |
!] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment