Всплывающая ajax-форма обратной связи в bitrix
Вызов компонента:
$APPLICATION->IncludeComponent("bitrix:form","sendCall",Array(
"AJAX_MODE" => "Y",
"SEF_MODE" => "Y",
"WEB_FORM_ID" => 1,
"RESULT_ID" => $_REQUEST["RESULT_ID"],
"START_PAGE" => "new",
"SHOW_LIST_PAGE" => "Y",
"SHOW_EDIT_PAGE" => "Y",
"SHOW_VIEW_PAGE" => "Y",
"SUCCESS_URL" => "",
"SHOW_ANSWER_VALUE" => "Y",
"SHOW_ADDITIONAL" => "Y",
"SHOW_STATUS" => "Y",
"EDIT_ADDITIONAL" => "Y",
"EDIT_STATUS" => "Y",
"NOT_SHOW_FILTER" => Array(),
"NOT_SHOW_TABLE" => Array(),
"CHAIN_ITEM_TEXT" => "",
"CHAIN_ITEM_LINK" => "",
"IGNORE_CUSTOM_TEMPLATE" => "Y",
"USE_EXTENDED_ERRORS" => "Y",
"CACHE_TYPE" => "A",
"CACHE_TIME" => "3600",
"AJAX_OPTION_JUMP" => "N",
"AJAX_OPTION_STYLE" => "Y",
"AJAX_OPTION_HISTORY" => "N",
"SEF_FOLDER" => "",
"SEF_URL_TEMPLATES" => Array(
"new" => "#WEB_FORM_ID#/",
/*"list" => "#WEB_FORM_ID#/list/",
"edit" => "#WEB_FORM_ID#/edit/#RESULT_ID#/",
"view" => "#WEB_FORM_ID#/view/#RESULT_ID#/"*/
),
"VARIABLE_ALIASES" => Array(
"new" => Array(),
"list" => Array(),
"edit" => Array(),
"view" => Array(),
)
)
);
Шаблон:
<?
if(!defined("B_PROLOG_INCLUDED") || B_PROLOG_INCLUDED!==true)die();
?>
<div class="modal-header">
<h5 class="modal-title" id="exampleModalLabel"><?=$arResult["FORM_TITLE"]?></h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">×</span>
</button>
</div>
<div class="modal-body">
<?if ($_REQUEST['formresult']=='addok') {
?>
<p><strong>Спасибо! Ваша заявка принята!</strong></p>
<script type="text/javascript">
$(document).ready(function(){
$('#sendCall')..show();
});
</script><?
}?>
<?if ($arResult["isFormErrors"] == "Y"):?><?=$arResult["FORM_ERRORS_TEXT"];?><?endif;?>
<?=$arResult["FORM_NOTE"]?>
<?if ($arResult["isFormNote"] != "Y")
{
?>
<?=$arResult["FORM_HEADER"]?>
<?
/***********************************************************************************
form questions
***********************************************************************************/
foreach ($arResult["QUESTIONS"] as $FIELD_SID => $arQuestion)
{
?>
<div class="form-group">
<?if (is_array($arResult["FORM_ERRORS"]) && array_key_exists($FIELD_SID, $arResult['FORM_ERRORS'])):?>
<span class="error-fld" title="<?=htmlspecialcharsbx($arResult["FORM_ERRORS"][$FIELD_SID])?>"></span>
<?endif;?>
<label for="mainFeedback_name"><?=$arQuestion["CAPTION"]?><?if ($arQuestion["REQUIRED"] == "Y"):?><span class="mf-control-required"><?=$arResult["REQUIRED_SIGN"];?></span><?endif;?></label>
<?=$arQuestion["IS_INPUT_CAPTION_IMAGE"] == "Y" ? "<br />".$arQuestion["IMAGE"]["HTML_CODE"] : ""?>
<?
if ($arQuestion['STRUCTURE'][0]['FIELD_TYPE'] == 'text') {
?><input type="<?=$arQuestion['STRUCTURE'][0]['FIELD_TYPE']?>" id="mainFeedback_name" name="form_<?=$arQuestion['STRUCTURE'][0]['FIELD_TYPE']?>_<?=$arQuestion['STRUCTURE'][0]['FIELD_ID']?>" class="form-control" value="" required=""><?
}
else
echo $arQuestion["HTML_CODE"];?>
</div>
<?
} //endwhile
if($arResult["isUseCaptcha"] == "Y")
{
?>
<b><?=GetMessage("FORM_CAPTCHA_TABLE_TITLE")?></b>
<input type="hidden" name="captcha_sid" value="<?=htmlspecialcharsbx($arResult["CAPTCHACode"]);?>" /><img src="/bitrix/tools/captcha.php?captcha_sid=<?=htmlspecialcharsbx($arResult["CAPTCHACode"]);?>" width="180" height="40" />
<?=GetMessage("FORM_CAPTCHA_FIELD_TITLE")?><?=$arResult["REQUIRED_SIGN"];?>
<input type="text" name="captcha_word" size="30" maxlength="50" value="" class="inputtext" />
<?
} // isUseCaptcha
?>
<input class="btn btn-primary" <?=(intval($arResult["F_RIGHT"]) < 10 ? "disabled=\"disabled\"" : "");?> type="submit" name="web_form_submit" value="<?=htmlspecialcharsbx(trim($arResult["arForm"]["BUTTON"]) == '' ? GetMessage("FORM_ADD") : $arResult["arForm"]["BUTTON"]);?>" />
<?=$arResult["FORM_FOOTER"]?>
<?
} //endif (isFormNote)
?>
</div>