A
A
Anto2020-11-08 23:11:46
1C-Bitrix
Anto, 2020-11-08 23:11:46

How to pass the title of the news to the form in the popup?

Good afternoon!
I have a page with a news component and each news has a button "Fill out the form", when you click on the button, a modal window pops up with the form.
In this form, in the field, I try to transfer the name of the news (so that it is automatically put in the form field) But this field "Name" is displayed for all news only for the first news, if I place the variable with the title in a non-block with popup, then the Name works correctly.

Tell me how can I pass the title to the field in the forms for each news?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
P
PetrPo, 2020-11-09
@ZIROKUL

1. In template.php inside the cycle by elements, below is an example, I think you will understand what to substitute where

<?foreach($arResult['ITEMS'] as $arItem):?>
  <?
  $popupId = randString(10, ['abcdefghijklmnop']);
  ?>
  
  <?//............................?>
  
  <a href="javascript:;" class="btn js-offer-request" data-fancybox="" data-src="#individual-tour-form_<?=$popupId;?>">
    <span>Забронировать экскурсию</span>
  </a>
  
  <?//............................?>
<?endforeach;?>

2. In the call of the form component, add a parameter, for example, after ON_NAME
"POPUP_ID" => $popupId
3. In the form component, add the template.php file
<?
$popupId = isset($arParams['POPUP_ID']) && $arParams['POPUP_ID'] ? '_'.$arParams['POPUP_ID'] : '';
?>
<div class="form-modal" id="individual-tour-form<?=$popupId;?>">

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question