Код компонента:
<?if (!defined("B_PROLOG_INCLUDED") || B_PROLOG_INCLUDED!==true)die();
if(isset($_SERVER["HTTP_X_REQUESTED_WITH"]) && !empty($_SERVER["HTTP_X_REQUESTED_WITH"]) && strtolower($_SERVER["HTTP_X_REQUESTED_WITH"]) == "xmlhttprequest") {
$GLOBALS["APPLICATION"]->RestartBuffer();
if (!empty($_REQUEST)) {
$v = new Validator($_REQUEST);
foreach ($arParams["REQUIRED_FIELDS"] as $prop) {
$v->rule("required", $prop)->label('');
}
$v->rule("regex", "PHONE", "((\+7|7|8)+([0-9]){10})")->label('');
$v->rule("email", "EMAIL")->label('');
$v->rule("accepted", "POLICY")->label('');
if($v->validate()) {
Helper::sendAjaxForm($arParams["IBLOCK_ID"], $_REQUEST);
} else {
$result = $_REQUEST;
$result["STATUS"] = false;
$result["ERRORS"] = $v->errors();
echo json_encode($result);
}
}
die();
} else {
if ($arParams["IBLOCK_ID"] > 0) {
$arResult["IBLOCK_ID"] = $arParams["IBLOCK_ID"];
}
if ($arParams["FIELDS"] && is_array($arParams["FIELDS"])) {
$arResult["FIELDS"] = $arParams["FIELDS"];
}
}
$this->IncludeComponentTemplate();
?>
Код подключения первого компонента:
<?$APPLICATION->IncludeComponent(
"foton:ajax-form",
"",
Array(
"IBLOCK_ID" => "17",
"FIELDS" => array(
"NAME" => array(
"TYPE" => "TEXT",
"TEXT" => "Имя",
"FIELD_CODE" => "FORM_NAME"
),
"PHONE" => array(
"TYPE" => "TEXT",
"TEXT" => "Телефон",
"FIELD_CODE" => "FORM_PHONE"
),
"MODEL" => array(
"TYPE" => "DROPBOX",
"TEXT" => "Интересующая модель",
"FIELD_CODE" => "FORM_MODEL"
),
"MODEL_ID" => array(
"TYPE" => "HIDDEN",
"FIELD_CODE" => "FORM_MODEL_ID"
),
"POLICY" => array(
"TYPE" => "POLICY",
"TEXT" => "Я согласен на обработку моих персональных данных"
)
),
"REQUIRED_FIELDS" => array("NAME", "PHONE", "MODEL", "POLICY")
)
);?>
Код подключения второго компонента:
<?$APPLICATION->IncludeComponent(
"foton:ajax-form",
"",
Array(
"IBLOCK_ID" => "14",
"FIELDS" => array(
"NAME" => array(
"TYPE" => "TEXT",
"TEXT" => "Ваше ФИО",
"FIELD_CODE" => "FORM_NAME"
),
"EMAIL" => array(
"TYPE" => "TEXT",
"TEXT" => "Ваш E-mail*",
"FIELD_CODE" => "FORM_EMAIL"
),
"PHONE" => array(
"TYPE" => "TEXT",
"TEXT" => "Ваш телефон",
"FIELD_CODE" => "FORM_PHONE"
),
"CITY" => array(
"TYPE" => "DROPBOX",
"TEXT" => "Выберите город*",
"FIELD_CODE" => "FORM_CITY"
),
"SUBJECT" => array(
"TYPE" => "DROPBOX",
"TEXT" => "Тема сообщения*",
"FIELD_CODE" => "FORM_SUBJECT"
),
"MESSAGE" => array(
"TYPE" => "TEXTAREA",
"TEXT" => "Текст сообщения*",
"FIELD_CODE" => "FORM_MESSAGE"
),
"POLICY" => array(
"TYPE" => "POLICY",
"TEXT" => "Я согласен на обработку моих персональных данных*"
)
),
"REQUIRED_FIELDS" => array("EMAIL", "CITY", "SUBJECT", "MESSAGE", "POLICY")
)
);?>
После подключения первого компонента во все последущие передается arParams["REQUIRED_FIELDS"] первого.
В какую сторону копать?)