S
S
Sergey Sofichev2017-07-27 11:04:02
1C-Bitrix
Sergey Sofichev, 2017-07-27 11:04:02

When connecting multiple components to a page, is the arParams of the first one passed to the next?

Component code:

<?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();
?>

Connection code for the first component:
<?$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")
    )
  );?>

Second component connection code:
<?$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")
  )
);?>

After connecting the first component, arParams["REQUIRED_FIELDS"] of the first one is passed to all subsequent ones.
In which direction to dig?)

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question